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.
it's a pity 8 years later, we still have to guess
Saved me from hours of debugging/testing.
Thank so much! That's it :)
This comment is hidden because it contains spoiler information about the solution
Thats what I am returning, I'm returning its @next field. I've tried it both with that and a new EmptyList just to be sure.
Nevermind, that was the issue. My problem wasn't with the ListNode code, but with the EmptyList push function.
That test expects more than just that the result be an empty list. It expects it to be the exact same empty list that was at the end of the list '(a)'.
I understand what the error message means, but mine won't pass that one either. I am returning an empty list in that case, I've tested it with my own test cases successfully. I KNOW I am returning an EmptyList and that it returns true for isEmpty(), but still no dice. Anyone else have this issue?
I'm a bit dissapointed with this kata series. Not only they're very easy, the tests do not cover every tricky case, opening doors for some cheap cheating.
This comment is hidden because it contains spoiler information about the solution
He just used high level functions for the purpose of this kata, with a simple algorithm in mind:
1: Get first line in order (left to right), using shift on the matrix you get the first line.
2: Last column in order (top to bottom), using map in the matrix, poping the last elements from every line.
3: Last line reversed (right to left), using pop in the matrix you get the last array, and then reverse it (because of the snail logic).
4: first column reversed (bottom to up), you again go through the entire matrix (using map) getting the first element (using shift) of each array, and then reverse it, since the other elements are being removed it works.
Do it all over again until there is no more items.
Hope it's clear enough.
Phew. Finally got a hold of remove() method, this one was tricky to guess right.
This comment is hidden because it contains spoiler information about the solution
That test removes
a
from a list containing onlya
, and expects to get back an empty list. The error message is describing what the test expects to happen, rather than what actually happened.Wow, that's not as easy as it looks.
I managed to pass all the test past this one: 'Removing 'a' from '(a)': Test Failed: l1.remove(first) is empty'.
Any hint? This seems a bit strange to me.
Why all those checks when you can do with just "array.length < 2" ;-)
Anyway, I like the solution, mainly because of its recursive nature.
Can someone elaborate what's going on there? (: It's a bit complicated.