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.
For Java, in your testcases, you may want to use
assertArrayEquals
instead ofassertEquals
got retired
Could do with more random tests
It might help, but notice that your soltion still crashes in one of ~five runs. Apparently, mutating the array only emphasized some other bug sitting somewhere there.
Thank you, Making a copy of
arr
did the trick.Additionally, in some cases your call to
is_pair(*start, *(start + 1))
seems to read past the end of the arr.The cause of your problem is the fact that your code mutates
arr
, and the changes you make to it destroy the data which is later used by tests to verify your result. Unfortunately, for some reason beyond my understanding, the solution function accepts the input as a non-const reference, and any mutation turns out to be destructive. You can resolve your issue by either making a copy ofarr
in your solution, or changing the function signature to acceptarr
by value or by const reference.I will fix the setup of the challenge and change the function signature some time soon, but I cannot give any ETA for that.
But isn't it more logical to cancel out everything even if it's not directly opposite? If 'NORTH, WEST, SOUTH, EAST' brings you to the same spot, why does tha kata request to not remove anything (because it's not directly opposite)? I'm just curious, as if I was to build a similar function in the future, I would do it my way
I didn't notice the feature of preloaded snippet. Thanks for pointing.
The class
Point
has to be put in the preloaded snippet, or tests must not rely on this class. I can changedistanceTo
to return always 0 and pass all random test by simply returningpoints
.getRandomNumber
can be justrnd.nextInt(lo, hi)
, orrnd.ints(lo, hi, count)
. There might be a part of "javascript" in "java" but let;s keep it only in the name, and not in this unnecessary "idiom" of getting a random integer.Resolved. Thank you for the pointer!
Noted. On it.
Random Tests test the user's solution against a repeat of itself.
This comment is hidden because it contains spoiler information about the solution
What is going on?
Time: 2708ms Passed: 0Failed: 4Exit Code: 1
Test Results:
Fixed_Tests
Basic_Tests
Expected: equal to [8.6667, 6.6667]
Actual: [8.6667, 6.6667]
Random_Tests
Moderate_Values
Expected: equal to [33, 37.3333]
Actual: [33, 37.3333]
High_Values
Expected: equal to [642.333, 895.667]
Actual: [642.333, 895.667]
Huge_Values
Expected: equal to [4697.33, 6422]
Actual: [4697.33, 6422]
Loading more items...