Created
October 3, 2009 00:55
-
-
Save djwhitt/200286 to your computer and use it in GitHub Desktop.
This file contains 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] | |
(let [s (.toString x) | |
l (.length s)] | |
(if (or (= l 0) (= l 1)) | |
true | |
(if (= (.charAt s 0) (.charAt s (- l 1))) | |
(palindrome? (.substring s 1 (- l 1))) | |
false)))) | |
(defn products [] | |
(map #(* (% 0) (% 1)) (for [i (range 100 1000) j (range 100 1000)] [i j]))) | |
(defn euler4 [] | |
(apply max (filter palindrome? (products)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment