Created
March 25, 2011 20:50
-
-
Save dbyrne/887605 to your computer and use it in GitHub Desktop.
Project Euler #36 - Clojure
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
(defn palindrome? [x] | |
(= x (apply str (reverse x)))) | |
(defn palindromic-2-10? [x] | |
(let [dec (Integer/toString x) | |
bin (Integer/toString x 2)] | |
(and (palindrome? dec) (palindrome? bin)))) | |
(with-test | |
(defn prob-36 [] | |
(apply + (filter | |
palindromic-2-10? | |
(range 1 1000000)))) | |
(is (= (prob-36) 872187))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment