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.
@GiacomoSorbi's JS and Ruby translations are completely wrong:
length
since it can be infinite. So why are you trying to get the length of the iterable?This goes on to show that the tests are far from sufficient and we need more actual iterables.
@Souzooka's C# translation is also wrong, it'll fail for
IEnumerable
s that is mutable (e.g if it's from anIEnumerator
).Also, needs random tests.
Thanks Voile, will keep that in mind next time :)
Yes, there are problems with the ruby version (actually JS version too). Gonna raise a separate issue.
Also, don't use
split("")
, usechars
. Learn best practices ;-)I don't think it works that way in ruby; you'd have to coerce it into an array with split("") before iterating....
Just go to issues and scroll and read. I'm pretty sure strings are not iterable in ruby. I'm no python expert so I can't comment, but according to others they seem to agree. Conceptually I don't see how you can iterate a string, that just doesn't make sense. You can coerce it into individual characters, but that's an array where each element is an individual string character.
Out of spec.
Where so???
Works perfectly in python, for example. I guess JS or ruby provide the same kind of thing.
Right, but as everyone else has been saying, a string isn't technically iterable either yet that is something we want to evaluate.
The description states that the input is a sequence. Meaning it is iterable. So having a simple number is out of the scope of the current task and falls in the domain of the "invalid inputs".
I think this kata is kind of confusing and there aren't enough test cases. For instance, you want "ABBBCD" to return ["A", "B", "C", "D"] here but what if the input was a pure integer 122234? Is this considered unique in that, that is a unique number different from any other integers, or should it return 1234? or should it return [1, 2, 3, 4]? Doesn't actually address a myriad of other inputs and what is expected of the output.
Not sure why you pasted your solution which is different from the onne that is being commented on, where it[0] is not 1 and is really undefined.
I think the problem is, the test case actually doesn't test for pure integers, and that's why it doesn't catch this.
This solution doesn't work if the input is 123334, but the test case is an integer array [1, 2, 3, 3, 4], where comparison is still valid and the returned array still works.