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.
Mh, I fear it is against the rules to give away the code that works "under the hood"; you can have a better luck printing the initial parameters and some intermediate steps until you get where the error is; remember that the sample tests you see are just a (small, usually) part of the whole course, so you may consider some edge test case.
I would go for a much simpler solution than yours, but that may be just me.
Also, when posting code, be sure to use the spoiler flag, so not to let others who did not complete it see your works [I flagged it for you now].
Hope this helps, happy coding :)