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.
That what I was thinking.
Comments would have been nice, however, this is a great solution in my opinion. Especially when compared to the monstrosity I came up with. I am somewhat of a newbie and I could understand the solution. When I see a solution like this I wonder what my mind does during the process of determining the best way to work this.
Some problems are inherently mathematical. And often, a mathematical solution is necessary, otherwise the computation is intractable. You might like to know that computers were basically invented to solve mathematical problems that had undergone 'mathematical transformations'.
Oops, right. I wasn't sure my solution would always work, but I trusted the test cases (am in no way proficient in maths).
If I understand the Kata correctly, item_index itself is also a zero based index, so:
item_indexes 0, 1, 2, 3 should return 0
item_index 4 should return 1
The other solutions are extremely slow so this would definitely be the best way to solve it if it was part of a bigger program.
This solution was for Python 2, and valid at that time.