Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
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.
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.
This comment is hidden because it contains spoiler information about the solution
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.
Same problem here in C++, looks like the tests exit silently :/
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.
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
C++ sample test cases use vector without including <vector> and without "using namespace std;", resulting in a compilation error.
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.
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.
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).
This comment is hidden because it contains spoiler information about the solution