Created
March 16, 2011 17:14
-
-
Save swannodette/872860 to your computer and use it in GitHub Desktop.
This file contains 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
(defn palindrome-o [x] | |
(exist [a b c d] | |
(digit-o a) (digit-o b) (digit-o c) (digit-o d) | |
(nonrel/project [a b c d] | |
(== x (* (+ (* 10 a) b) | |
(+ (* 10 c) d))) | |
(nonrel/project [x] | |
(== (> x 0) true) | |
(== (>= x 100) true) | |
(== (mod (int (/ x 1000)) 10) | |
(mod (int (/ x 1)) 10)) | |
(== (mod (int (/ x 100)) 10) | |
(mod (int (/ x 10)) 10)))))) | |
(defn palindrome [] | |
(let [r (range 9)] | |
(for [a r b r | |
c r d r | |
:let [x (* (+ (* 10 a) b) | |
(+ (* 10 c) d))] | |
:when (and (> x 0) | |
(>= x 100) | |
(= (mod (int (/ x 1000)) 10) | |
(mod (int (/ x 1)) 10)) | |
(= (mod (int (/ x 100)) 10) | |
(mod (int (/ x 10)) 10)))] | |
x))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment