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.
Nice kata!
Nice kata, thank you!
Decided to use a different tack to finish with this kata. I learned a lot. It would be interesting to see a solution using Regular Expressions especilly since the kata is tagged with this category. Additionally, having spent significant time reading around this topic quite a lot, I couldn't quite see how to solve the kata incorporating RegEx into the solution.
Thank you for a great kata.
Thank you for your very thoughful reply. The snippet you sent goes a long way to explaining how the guard statement logic works here. If the guard statement is commented out, the recursion has no way to stop it. What is also a very useful takeaway is the acknowledgement that a return statement will halt the function except when it contains a recursive component. Then another mechanism may be required to stop execution e.g. the guard statement in this case.
This comment is hidden because it contains spoiler information about the solution
This is a lovely solution. When I test it, empty arrays are returned when they are inserted in the input array. Interestingly, not all of the empty arrays are returned...
flattenTwoLevels([1, [], [2, 3],[4, 5, [6, 7, 8], 9, [], 10, [11, [12, [13, 14], 15], 16], 17], [], 18]) ->
[1, [], [2, 3], [4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17], [], 18]
I also like your solution, but when I test it with the following function call, empty arrays are returned - but not all of them...
flattenTwoLevels([1, [], [2, 3],[4, 5, [6, 7, 8], 9, [], 10, [11, [12, [13, 14], 15], 16], 17], [], 18]) ->
[1, [], [2, 3], [4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17], [], 18]
This is a lovely solution. When I test it it works beautifully but returns empty arrays if present in the input array.
Any help for how to add random tests in Test cases, would be welcome. Thank you.
Very nice kata. Thank you!
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
Loading more items...