Created
March 29, 2016 00:54
-
-
Save chrisguitarguy/dba464e673e76f1d97a1 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
| (defn- read-int-line [] | |
| (Integer/parseInt (read-line))) | |
| (defn- spring? [current-cycle] | |
| (= 0 (mod current-cycle 2))) | |
| (defn- tree-height-after [total-cycles] | |
| (loop [current-cycle 0 | |
| height 1] | |
| (if (>= current-cycle total-cycles) | |
| height | |
| (recur (inc current-cycle) (if (spring? current-cycle) (* 2 height) (inc height)))))) | |
| (defn run [] | |
| (let [tc-count (read-int-line) | |
| test-cases (repeatedly tc-count read-int-line)] | |
| (doseq [total-cycles test-cases] | |
| (println (tree-height-after total-cycles))))) | |
| (run) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment