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.
100%, however, still impressive how simple it could have been done if we were to guess the string would be so short haha
Added
Random tests added to Ruby
Can you explain why flatten is better?
Thanks, Added.
Give me more information. Do you get an exception? Whats not working about the code?
Thanks! Should be better now.
cheers! btw I think it's something to do with the CodeWars testing environment. I had to move your MySuperTest class inside the describe block to get it in scope.
I'm a little confused as to the error you're reporting, because
find_the_ball(1, [])
is not one of the test cases. There are no test cases for Ruby with an emptyswaps
list (although returning the start position would be the correct solution if there was)....Aha! Got it. Multiple tests used the same
swaps
array. But your solution mutates that array, which means that the second time it's used the test that's being run doesn't match the test it thinks is being run.I've changed the tests so that this should no longer be an issue, but I would point out that it's poor practice to mutate the array passed in like that, for precisely this reason - it can lead to hard-to-find errors.
That's not a solution to the problem. Have a look at mcquackers' earlier comment and see if that helps clarify things.
If you still think there's a problem with a test, can you tell me which one?
This comment is hidden because it contains spoiler information about the solution
can you suggest how to improve it? This is my first kata so I didn't really know what I was doing.
It seems that in your solution 'observed' is a string but it is an int, doesn't it?
This comment is hidden because it contains spoiler information about the solution
Convention that denotes an unused variable that is passed to the block. It actually has a special syntactic meaning in that it's the only variable name that can appear multiple times, e.g.
[].map.with_index { |x, x| }
is invalid while[].map.with_index { |_, _| }
is valid.Loading more items...