Over at Hacker News an article was posted called Embarrassing code I wrote under stress at a job interview. In it the author describes some code he wrote while doing a job interview. He was obviously not very happy with it, hence the embarrassing of the title. The problem which he was asked to solve was called happy numbers.
Wikipedia describes the a happy number as follows:
A happy number is a number defined by the following process: Starting with any positive integer, replace the number by the sum of the squares of its digits, and repeat the process until the number equals 1 (where it will stay), or it loops endlessly in a cycle which does not include 1. Those numbers for which this process ends in 1 are happy numbers, while those that do not end in 1 are unhappy numbers (or sad numbers)
So, as I am learning
clojure I figured I would give it a go as well. Luckily for me nobody was looking of my shoulder and I have access to the internet, so I could go and find some information about things like
You can use this code in a variety of ways, which is always nice. Here are some examples:
If you have any feedback on the code, please post a comment below! I would greatly appreciate the feedback.