Skip to content

Instantly share code, notes, and snippets.

@trikitrok
Created November 20, 2014 19:33
Show Gist options
  • Save trikitrok/ddb8a1731874542a4d15 to your computer and use it in GitHub Desktop.
Save trikitrok/ddb8a1731874542a4d15 to your computer and use it in GitHub Desktop.
; ...
(defn num-neighbors-being-a-cell [cell cells]
(count (filter (neighbors cell) cells)))
(defn has-cell? [loc cells]
(= loc (some #{loc} cells)))
(defn will-have-a-cell? [loc cells]
(let [num-neighbors (num-neighbors-being-a-cell loc cells)]
(or (= num-neighbors 3)
(and (= num-neighbors 2)
(has-cell? loc cells)))))
;...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment