Skip to content

Instantly share code, notes, and snippets.

@djwhitt
Created October 3, 2009 00:55
Show Gist options
  • Save djwhitt/200286 to your computer and use it in GitHub Desktop.
Save djwhitt/200286 to your computer and use it in GitHub Desktop.
(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