Skip to content

Instantly share code, notes, and snippets.

@lenaschoenburg
Last active December 12, 2015 00:18
Show Gist options
  • Save lenaschoenburg/4682364 to your computer and use it in GitHub Desktop.
Save lenaschoenburg/4682364 to your computer and use it in GitHub Desktop.
(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