Skip to content

Instantly share code, notes, and snippets.

@zahardzhan
Created February 16, 2010 09:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zahardzhan/305420 to your computer and use it in GitHub Desktop.
Save zahardzhan/305420 to your computer and use it in GitHub Desktop.
(defn up [] (int (Math/pow -1 (inc (.nextInt (new java.util.Random) 2)))))
(first (filter (partial = 10) (iterate #(+ % (up)) 0)))
(let [position (atom 0)
movements (cycle [-1 1 1])]
(defn up1 []
(reset! position (inc @position))
(nth movements @position)))
(first (filter (partial = 10) (iterate #(+ % (up1)) 0)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment