Last active
December 12, 2015 00:18
-
-
Save lenaschoenburg/4682364 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 middle [s] | |
(int (/ (count s) 2))) | |
(defn left [s] | |
(take (middle s) s)) | |
(defn right [s] | |
(if (even? (count s)) | |
(drop (middle s) s) | |
(drop (+ 1 (middle s)) s))) | |
(defn palindrom? [number] | |
(let [numbers (seq (str number)) | |
left (left numbers) | |
right (right numbers)] | |
(and (= left (reverse right)) | |
(> (count numbers) 1)))) | |
(defn cross [s1 s2] | |
(for [e1 s1 | |
e2 s2] | |
(* e1 e2))) | |
(first (sort > (filter palindrom? (cross (range 1000) (range 1000))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment