Ad
  • Custom User Avatar

    Is it normal for the C++ "Complex 1" test to be so long? It seems to make nested loops with so many iterations that my program ends up in a timeout. The program is {"mov a 1", "mov b 1", "mov c 0", "mov d 26", "jnz c 2", "jnz 1 5", "mov c 7", "inc d", "dec c", "jnz c -2", "mov c a", "inc a", "dec b", "jnz b -2", "mov b c", "dec d", "jnz d -6", "mov c 18", "mov d 11", "inc a", "dec d", "jnz d -2", "dec c", "jnz c -5" }.

    When I test it with a lower value of d for the 4th instruction, the program manages to finish before timing out. For example, with mov d 13, I get [ ("c", 0), ("b", 377), ("d", 0), ("a", 808) ] as a return.

    EDIT: Nevermind, for some reason now it works... I guess the servers were a bit too busy at some point.

  • Custom User Avatar

    5 isn't a peak there, 6 is greater than it. And 6 can't be a peak because of this:

    The first and last elements of the array will not be considered as peaks

  • Custom User Avatar

    One of your test cases is still not correct, i mean this one:
    v: [ 2 1 3 2 2 2 2 5 6 ] peaks: [ 3 ] --- pos: [ 2 ]

    You have two peaks instead of just one: [ 2 1 3 2 2 2 2 5 6 ] at positions: 2 (peak 3 )and also at 7 (peak 5)

  • Custom User Avatar

    EDIT : Answering you, I decided to run a few more debugging tests, just to be on the safe side. It turns out v.size() returns an unsigned value, and in the case v is empty, v.size() - 1 overflows and gives a big positive value instead of -1, which allows the code to enter the "for" loop and the segfault occurs there.

    I feel really dumb.

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    Issue not specified, closing.

    @ziemowit141, it seems your helper function is wrong, and there're mistakes in your code not related to the algorithm.

  • Custom User Avatar

    150 completions in C++ including one I've just done. Could you give an example of a test you can't pass but you think you should be passing (i.e. input array, pos and peaks array you return, error message you receive)? Alternatively, one of you could post your solution here with a spoiler tag (and preferrably with the proper code-block markdown).

    Also, can verify that the fixed tests posted above by @Alderi-Tokori are all correct and in case you fail them, your algo is 100% NOT working correctly.

  • Custom User Avatar

    shrug I just gave up. I don't want to solve it in another language where tests work correctly just because the C++ tests are crappy, I've got my solution and it works, if one day the tests are fixed I'll get my points.

  • Custom User Avatar

    The same story here, any solution to get points for this task? I've tried my code locally and it computes peaks from failing test cases correctly :/

  • Custom User Avatar

    yea having the same issue, even managed to get my hands on some of the random test cases and on my machine the awnser was what was expected by the test cases.

  • Custom User Avatar

    Same problem here in C++, looks like the tests exit silently :/

  • Custom User Avatar

    Some problem using c++, the tests seem to fail (or, at least, exit prematurely) silently. I added a debug output to my program and it seems to fail after the should_pass_all_fixed_and_edge_assertions, here is the output of these tests:
    v: [ 1 2 3 6 4 1 2 3 2 1 ]
    peaks: [ 6 3 ] --- pos: [ 3 7 ]
    v: [ 3 2 3 6 4 1 2 3 2 1 2 2 2 1 ]
    peaks: [ 6 3 2 ] --- pos: [ 3 7 10 ]
    v: [ 2 1 3 1 2 2 2 2 1 ]
    peaks: [ 3 2 ] --- pos: [ 2 4 ]
    v: [ 2 1 3 1 2 2 2 2 ]
    peaks: [ 3 ] --- pos: [ 2 ]
    v: [ 2 1 3 2 2 2 2 5 6 ]
    peaks: [ 3 ] --- pos: [ 2 ]
    v: [ 2 1 3 2 2 2 2 1 ]
    peaks: [ 3 ] --- pos: [ 2 ]
    v: [ 1 2 5 4 3 2 3 6 4 1 2 3 3 4 5 3 2 1 2 3 5 5 4 3 ]
    peaks: [ 5 6 5 5 ] --- pos: [ 2 7 14 20 ]

    From what I can tell my program detects all the peaks and their position correctly, there seems to be a problem with the C++ tests.

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    Fixed. (#include seems to be not necessary.)

  • Loading more items...