Solve problem 112 using C++/Clojure/Python/Ruby.