Created
December 21, 2011 12:26
-
-
Save anonymous/1505853 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
| ;; jgustak's solution to Analyze a Tic-Tac-Toe Board | |
| ;; https://4clojure.com/problem/73 | |
| (fn tictac [mtx] | |
| (let [xs (concat mtx | |
| (vec (apply map vector mtx)) | |
| [(for [x [0 1 2]] (get-in mtx [x x])) | |
| (for [x [0 1 2]] (get-in mtx [x (- 2 x)]))]) | |
| who (fn [ys] | |
| (and (apply = ys) (not= (first ys) :e) (first ys)))] | |
| (loop [xs xs] | |
| (when (seq xs) | |
| (if-let [winner (who (first xs))] | |
| winner | |
| (recur (rest xs))))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment