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.
Pretty cool, but incredibly slow.
yes, crap :)
If
str_in
is empty string thenout[2*strlen(str_in)-1]
is unallocated memoryHmm I don't get it.. It says all Java testcases passed green and then below it says it timed out after 16s, however the sum of each test duration is roughly 5s, nowhere near 16s. Is it still just my solution that is slow or something else?
Test Results:
SolutionTest
basicTests
Test Passed
Completed in 1ms
RandomTests_shortArrays
Test Passed
Completed in 1508ms
BiggerFixedTests
Test Passed
Completed in 3211ms
RandomTests_biggernums
Test Passed
Completed in 450ms
fixedTests_larger_arrays
Test Passed
Completed in 2ms
STDERR
Execution Timed Out (16000 ms)
In the "Really close to target" test case I think the arrow hits inside r2 but outside r1, which is weird since r2 is supposed to be smaller than r1 (r1=1.0 r2=4.0). The reference seems to just give 0 points if it hits outside r1, even if it is inside r2.. But I suppose the test should be changed so that r2 < r1. Nice kata by the way!
you are completely correct! many thanks for pointing this out. I have done some, uh, heavy refactoring, including adding your critical example to the test suite. ;)
Yes have you tried that (made up) test with the above code? I think it will output {1, 2, 4} instead. In the solution function local[0] == local[1]. Then minab = local[0] + 1 != local[1], which breaks the loop and output]1] will be wrong...
I had a bit random problems with this when doing the kata : )
that's a correct test. [0] (min) = 1, [1] (next smaller number not in the array) = 3, [2] (max) = 4
If there is another number after the duplicate, e.g:
{
const int test_arr[4] = {1, 1, 2, 4};
const int expected[3] = {1, 3, 4};
tester(test_arr, 4, expected);
}
I'm not sure I follow you. The "solution" function does not assume unique numbers. It is designed to handle duplicates.
I think the random tests can produce duplicates but the "solution" function assumes unique numbers to always give valid output..