Skip to content

Instantly share code, notes, and snippets.

@ypsilon-takai
Created November 17, 2011 10:09
Show Gist options
  • Select an option

  • Save ypsilon-takai/1372840 to your computer and use it in GitHub Desktop.

Select an option

Save ypsilon-takai/1372840 to your computer and use it in GitHub Desktop.
project euler 62
;; Problem 62 : 2011/11/17
;; "Elapsed time: 2139.92309 msecs"
(defn pe62 [tgt-count]
(loop [num 9
res-map {}]
(let [cubed (* num num num)
num-key (sort (num-to-list cubed))]
(if (= (dec tgt-count) (count (res-map num-key)))
(cons num (res-map num-key))
(recur
(inc num)
(assoc res-map num-key (cons num (res-map num-key))))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment