Today’s problem had to do with Happy Numbers.
I split the problem up in two parts, splitting up a number up in to digits and checking whether or not the number is a Happy Number.
The first part I implemented in two different ways.
Method 2 is shorter and faster, but I really wanted to try solving it by just using numbers. String conversions feel a bit “dirty”.
Then finally, checking whether a number is a happy number or not:
The source can also be found on Bitbucket.