Created
November 17, 2011 10:09
-
-
Save ypsilon-takai/1372840 to your computer and use it in GitHub Desktop.
project euler 62
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ;; 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