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.
OP solved it, closing
Empty arrays are not in the challenge. That said, it was an interesting challenge to address.
The reason some are removed is the flattening logic removes and second level and beyond empty arrays.
To remove the first level empty arrays, add a filter to the return value:
.filter { !(($0 as? Array<Any>)?.isEmpty ?? false) }
that should be clear from the type of the function, and in this way it is better readable
lmaoooo
I made a change in the way I pick my steps and it finally worked, haha!
I was about to give up and go to sleep, but it's your comment that gave me hope for a last try. ^_^
Thank you! :D
Yes, it's elegant. But at the same time, it needs to iterate all the range from zero to n. I think this way wastes a lot of time when n is a big number.
This comment is hidden because it contains spoiler information about the solution
I second this.
There should be a clarification in the description that multiples of both 3 and 5 should be included just once in the sum.
For example, 30 = 5 * 6, but also 30 = 3 * 10. The same is for 15, 45, 60, etc. In the current tests those numbers go once in the sum.
Agreed.
I was wondering the same thing, so I ran a little experiment to understand how that's working:
When I run this with an input of 10, the print statement on line 3 produces a series of numbers counting down from 10, each in an array (i.e. [10], [9], and so on). The final iteration returns nil, which is triggered by the guard statement in line 2, which allows the recursion to stop running. It is the exit mechanism. I hope that helps.
Thanks!
Comments inside kumites are not visible to people who have not solved the kata.Turns out this is true in some cases, but comments under translations are visible to everybody...See my fork, you've forked your original translation. Also remember to delete the last comment in your initial translation, it's giving away the solution, it can't be marked as having spoiler content.
Try to delete the comment with the solution in the translation discussion, you're giving it away ;)
Loading more items...