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.
Rejected:
No sample tests
No tests to begin with
Outdated version
Please refer here on how to make corresponding changes and publish a new fork
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.
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.
This comment is hidden because it contains spoiler information about the solution
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
Loading more items...