Skip to content

Instantly share code, notes, and snippets.

@amalloy
Created August 15, 2011 22:42
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 amalloy/1148071 to your computer and use it in GitHub Desktop.
Save amalloy/1148071 to your computer and use it in GitHub Desktop.
;; Project Euler problem 4
;; Largest palindrome which is a product of two three-digit numbers
(apply max (for [x (range 1000), y (range x)
:let [prod (* x y)]
:when (apply = ((juxt seq reverse) (str prod)))]
prod))
;; or without juxt:
(apply max (for [x (range 1000), y (range x)
:let [prod (* x y), s (str prod)]
:when (= (seq s) (reverse s))]
prod))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment