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.
Fixed.
This comment is hidden because it contains spoiler information about the solution
? In the tests mine was okay
I confirm tests generate invalid inputs see my submitted solution.
Mine also fails. Seems to be an issue with the tests.
In the example provided, the results differ starting from the word
them
.them
is a longer word thanthe
, sothem
is expected to be selected as the longest valid word starting from thet
.You may want the algorithm to be able to distinguish that
["the", "middle]"
make more sense than["them", "id", "d", "l", "e"]
, but that is what the algorithm does. The kata is about coding that algorithm, not about segmenting the words as a human would expect.It would eventually crash. Though, the problem desctiption states that there's always a loop, so I didn't include the null check in the while loop.
BTW: I didn't know that solution passed... if was failing on the last test (but only here on codewars for some reason).
EDIT: Please ignore my misplaced comment :)
it would most probably crash.