Completing my first Reddit programming challenge

Today, I completed my first daily /r/programmerchallenge! The sub-reddit features three levels of challenges from easy to advanced and a weekly challenge. It was an interesting math-related challenge, which I decided to write in Python 3 as that’s what I’ve used the most lately.

As Wikipedia explains, “a Kaprekar number for a given base is a non-negative integer, the representation of whose square in that base can be split into two parts that add up to the original number again. For instance, 45 is a Kaprekar number, because 452 = 2025 and 20+25 = 45.”

Below is my solution, which is not the prettiest or the shortest but returns the right answer. I also read through other people’s solutions in Java, Python and Scala. In the future, I’ll try to solve a challenge in more than one language.