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.
Code optimization is quite difficult for this problem. Thanks for your advice.
I think there should be an example where a term of the sum is divided more than one time. For example:
k-divide(8, 2) = sum(1, 1, 3, 1, 5, 3, 7, 1) = 22
The first time I didn't catch the part about repeating the operation, as the instruction mentioned dividing twice. My fault, but I think the it could be rewritten clearer and shorter. Maybe
For each integer from 1 to N, perform the following operation:
Like others said, some code solves this kata in 1 second. So it CAN get optimised.
It doesnt fail your random test, your code supposedly is just unoptimized and takes too long to calculate, like my code, but I dont see a way how to optimize my code even further
My solution passes all the 63 tests, but fails the random tests.
This was a very challenging exercise.