I’m trying to write a quick solve for Kaprekar number’s to show a friend of mine how easy it is to implement something like this in Python. I know how to do all the steps except for iterating through the squared number as a string. For example 45 is a Kaprekar number because
45 ** 2 = 2025 and 20 + 25 = 45
What I’m trying to write is code that would take the result of 45 ** 2 = 2025 and let me iterate over the combinations like
[‘2’, ‘025’]
[’20’, ’25’]
[‘202’, ‘5’]
1 Answer