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.
Linked list is a duplicate to a million existing katas.
Tests are incredibly weak: most tests only involve at most 2 nodes. And there are no random tests.
There are two kinds of
to_a
in the tests: the instance methodto_a
and the class methodto_a
. They're redundant.There's nothing to stop us from implementing
reverse
by converting it to array, reversing it as an array, then converting it back.And then suddenly you're putting in a
Range
object intofrom_a
? Isn't the meaning offrom_a
, well, do something from an array? What's aRange
doing here? By this rate I wouldn't be surprised if we'd have to supportString
s andEnumerator
s as well.Did you really think through the requirements when you made this kata? Because it's obvious you don't, you just slap together a bunch of stuff about linked lists and expect people to contemplate into what you were thinking about when writing the tests.
Besides, you didn't really write up any kind of documentation. If you've done that you should've already seen through most of the problems mentioned above.
Needs sample tests
It's not clear how the
String
representation of aNode
object is supporsed to look:one #=> <Node @name=1, @next=nil>
two #=> <Node @name=2, @next=<Node @name=1 @next=nil>>
Note, how this is inconsistent: For the second case I'd expect a comma between the value of the
@name
and ```@nextIn other words:
two #=> <Node @name=2, @next=<Node @name=1, @next=nil>>````How about fixing this by having the comma in both cases (in fact all cases -- in case of a longer list)?
Depending on how detailed the test for the this kata are, it can be confusing for users to fail because of this, without adding to the point of the kata (which is understanding a singly linked list).
I, too, really liked this kata and going back to the basics to implement a simple data structure. The couple of comments I have are as follows:
from_a
method actually needs to handle ranges and arrays.reverse
,from_a
,to_a
(class), andto_a
(instance)). The complete list of required methods can be gleaned from the given Text Examples, but it'd be nicer to have everything explicitly listed.