Last active
August 29, 2015 14:24
-
-
Save julianjelfs/81e2dd976625f31574ff 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 relative-to [prev next] | |
(if prev | |
(let [[pr pc] prev | |
[nr nc] next] | |
[(+ pr nr) (+ pc nc)]) | |
next)) | |
(defn tetrominos | |
"all tetrominos start at [0 0]" | |
([] (tetrominos [[0 0]])) | |
([so-far] | |
(if (= 4 (count so-far)) | |
so-far | |
(mapcat identity (for [c [[-1 0] [1 0] [0 -1] [0 1]]] | |
(tetrominos (conj so-far (relative-to (last so-far) c)))))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment