First solution in clojure
Tested on some inputs