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

    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

    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

    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

    C++ sample test cases use vector without including <vector> and without "using namespace std;", resulting in a compilation error.

  • Custom User Avatar

    Hint: to calculate the sum of all proper divisors of a number n, you don't need to test every number up until n / 2.

  • Custom User Avatar

    Ah probably, if the error you receive is a timeout after 12 seconds, then that means you have to optimize your code. Hint: to calculate the sum of all proper divisors of a number n, you don't need to test every number up until n / 2.

  • Custom User Avatar

    There shouldn't be a main in your code, and check if your function names are the same as in the base skeleton code (this is important because the unit tests are calling those function names).

  • Custom User Avatar

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