Skip to content

Instantly share code, notes, and snippets.

Created September 16, 2011 17:48
Show Gist options
  • Save anonymous/1222680 to your computer and use it in GitHub Desktop.
Save anonymous/1222680 to your computer and use it in GitHub Desktop.
;; fronx's solution to Analyze a Tic-Tac-Toe Board
;; https://4clojure.com/problem/73
(fn [m]
(first
(filter
(fn [p]
(if (empty?
(->> (concat m
(map (fn [i]
(map #(% i) m))
'(0 1 2))
(vector (map #((m %) %)
'(0 1 2)))
(vector (map #((m (- 2 %)) %)
'(0 1 2))))
(map (fn [row]
(count (filter #(= p %) row))))
(filter #(= % 3))))
nil
p))
[:x :o])))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment