Created
August 13, 2013 07:29
-
-
Save aterreno/6218688 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 go-right [[x y]] {:pos [(inc x) y]}) | |
(defn go-left [[x y]] {:pos [(dec x) y]}) | |
(defn go-down [[x y]] {:pos [x (inc y)]}) | |
(defn go-up [[x y]] {:pos [x (dec y)]}) | |
;; I'm pretty (cool) and I know it! | |
(defn enterprise-buzz | |
"To infinity and beyond!" | |
[look {[x y] :pos}] | |
(println (look [ x y])) | |
(let [up (not (look [x (dec y)])) | |
down (not (look [x (inc y)])) | |
right (not (look [(inc x ) y])) | |
left (not (look [(dec x) y])) | |
pair [x y]] | |
((if right go-right | |
(if up go-up | |
(if left go-left | |
(if down | |
go-down )))) | |
pair))) | |
;; Work in progress | |
(defn greedy-buzz | |
[look {[x y] :pos}] | |
) | |
(defn path-length [look x-fn y-fn x y] | |
(count (take-while | |
(complement nil) | |
(map look | |
(iterate (fn [[ x y]]) | |
[(x-fn x) (y-fn y)]))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment