Skip to content

Instantly share code, notes, and snippets.

@raine
Created July 2, 2012 13:26
Show Gist options
  • Select an option

  • Save raine/3033241 to your computer and use it in GitHub Desktop.

Select an option

Save raine/3033241 to your computer and use it in GitHub Desktop.
;; Problem 4
;;
;; A palindromic number reads the same both ways. The largest palindrome made
;; from the product of two 2-digit numbers is 9009 = 91 99.
;;
;; Find the largest palindrome made from the product of two 3-digit numbers.
(defn is-palindrome? [s]
(let [s (str s)]
(= s (str/reverse s))))
(defn problem-4-1
[]
(apply max (for [x (range 100 1000) y (range x 1000)
:let [m (* x y)]
:when (is-palindrome? m)] m)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment