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.
I was starting to create an implementation of BigInt that allowed me to multiply and get the modulo of large numbers while storing them as strings. And then I realized that the solution was waaaaaay simpler than that.
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
There's sometimes a problem with the client when trying to submit solutions. Refreshing the page usually solves the "unknown error" issue.
The "6000ms" error is 99% of the time due to an unoptimized algorithm. The Kata details hint at the algorithm needing to work with big numbers. Iterating through all the numbers won't work in the time constraint.
I'd say my solution was a little brute forced. I recursively stripped the variable, so each iteration of my loop was faster than the last since it was producing a number that was the log5 of the last
The difficulty of this kata comes from the mathematical component, not the programming one. It is a fun math problem, but it would be a lot more satisfying if it were solvable by brute (but optimized force) as well. Unfortunately, the Codewars' platform time and memory constraints are too low to allow any solution other than using the little math "trick" (speaking of my own Python solutions here).
It was interesting trying to come up with optimizations to what I thought was a good approach to the problem, even if I didn't get the satisfaction of actually passing the large number test. And I also learnt the difference between range() and xrange(), so that counts as well :P
This is so much cleaner than the current top voted solution.