Skip to content

Instantly share code, notes, and snippets.

@bhenry
Created June 10, 2010 14:50
Show Gist options
  • Save bhenry/433107 to your computer and use it in GitHub Desktop.
Save bhenry/433107 to your computer and use it in GitHub Desktop.
;;problem 14
(defn do-to-odd [x]
(+ 1 (* 3 x)))
(defn do-to-even [x]
(/ x 2))
(defn get-next [x]
(if (zero? (mod x 2))
(do-to-even x)
(do-to-odd x)))
(defn get-sequence [start]
(if (= 1 start)
1
[start (get-sequence (get-next start))]))
(defn get-seq-length [start]
(count (flatten (get-sequence start))))
(defn get-max-vec [v1 v2]
(if (pos? (compare (second v1) (second v2)))
v1
v2))
(reduce get-max-vec (for [x (range 1 1000000)]
[x (get-seq-length x)]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment