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.
@Blind4Basics, how do you know that several times the same input gives different results?
Yes, you are right.
Wouldn't using set ensure the result is sorted though?
I don't think error handling is expected in this kata. I assumed that there's always enough input, and it worked.
(C++) The expected behaviour with regards to running into the end of the input string should be described more carefully. I had to use the input data to reverse engineer the expected behaviour...
C++
what language?
Can you simplify this? Do you see some commonalities in the code paths?
n873, I don't know about the test case you are pointing at (I am looking at the test cases and see none of length 6, but maybe the generated ones could have one), but FArekkusu is right, your solution has a flaw. You assume that unravelling the array from both ends simultaneously should yield opposite pairs, but this is not the case. In addition to FArekkusu's case, here is another which breaks. This is essentially a loop, with a little side trip to get the length to 10: eennnswwss. I think you need to change tactics and count n/s and e/w separately, like x and y on a graph, and see if they sum to zero, separately. Try to plot the walks on paper and see if that gives you the idea.
Could it be that there is a test with an invalid direction? The code looks like it should work. Try testing explicitly for 'e'. ==> Edit: it seems not, all test cases are valid. Hm.
Btw, n/s as x is rather unusual :)
Someone's "solution" sneaked through even though he was only keeping track of n/e as + and s/w as - in a single variable, so nnnnnwwwww would land him back at start, in his code. There needs to be a test case to prevent this from working.
Thank you, fixed it
What is time for?
This doesn't work: walk = { 'n', 'n', 'n', 'n', 'n', 'w', 'w', 'w', 'w', 'w' }
You need to track both n/s and e/w separately.
It creates an array of size ASCII value of 'Z' plus one, and initialises all of them to zero. Somewhat wasteful on space, but makes some later logic easier.
Loading more items...