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.
It is stated in the kata that array is never empty
bug: if arr is empty, it will return 1 instead of 0.
Nice, i have noticed same pattern from basics tests but i didnt even try it.I over engineered it as much i could haha :O
This comment is hidden because it contains spoiler information about the solution
I rearranged and simplified the formula for sum of elements of arithmetic sequence, and this simple formula came out.
One tricky part was determining how many odd numbers should be used in the sum, but as I remember it was also represented by some arithmetic sequence.
Now I don't remember the exact steps I have taken but if you want to understand it, you should look at it as arithmetic sequences.
How does it work?