Created
July 2, 2012 13:26
-
-
Save raine/3033241 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| ;; 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