Skip to content

Instantly share code, notes, and snippets.

@funkotron
Created February 15, 2014 02:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save funkotron/9013877 to your computer and use it in GitHub Desktop.
Save funkotron/9013877 to your computer and use it in GitHub Desktop.
Problem 4 of Project Euler in Clojure
(defn palindrome?
"Is x the same read backwards?"
[x]
(let [s (seq (str x))]
(= s (reverse s))))
(def three-digit-products
"All the products of two three-digit numbers"
(for [x (range 100 999)
y (range 100 999)]
(* x y)))
;; Find the maximum number composed of two three-digit
;; products that is a palindrome.
(reduce max (filter palindrome? three-digit-products)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment