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.
Thank you for the fast reply! I had made a basic error in thinking about how the totient works for non-coprime values.
The Kata tests positive now (not for any virus, thankfully). Excellent Kata, by the way: just started using codewars, and it was a lot of fun training this Kata. Plus, I learned something interesting.
On my attempt I receive a fairly odd failed test (for random inputs):
Test tower(6, 2, 8)
4 should equal 0
Given that 6^6 mod 8 = 4 I am confident my code is correct in this case, while the Python test seems to be incorrect. My attempt also fails at multiple other tests for larger inputs, e.g.:
Test tower(30318, 1648, 586)
582 should equal 430
Here I don't know which is correct, but a brute force tower code I wrote for testing using totient phi(586)=292 produces the same result as the optimised code, i.e. 582. Now I am wondering whether this, too, is an issue with the tests or with my attempt at a solution.