Forked from anonymous/fronx-4clojure-solution73.clj
Created
September 16, 2011 17:49
-
-
Save fronx/1222682 to your computer and use it in GitHub Desktop.
Revisions
-
fronx revised this gist
Sep 16, 2011 . 1 changed file with 15 additions and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -13,4 +13,18 @@ (map (fn [row] (count (filter #(= player %) row)))) (filter #(= % 3)) seq)) [:x :o]))) ; [ ; ; rows ; [a b c] ; [d e f] ; [g h i] ; ; columns ; [a d g] ; [b e h] ; [c f i] ; ; diagonals ; [a e i] ; [g e c] ; ] -
fronx revised this gist
Sep 16, 2011 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -12,4 +12,5 @@ (vector (map #((m (- 2 %)) %) idx)))) ; diagonal 2 (map (fn [row] (count (filter #(= player %) row)))) (filter #(= % 3)) seq)) [:x :o]))) -
fronx revised this gist
Sep 16, 2011 . 1 changed file with 5 additions and 6 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -6,11 +6,10 @@ (filter (fn win? [player] (->> (let [idx [0 1 2]] (concat m ; rows (map (fn [i] (map #(% i) m)) idx) ; columns (vector (map #((m %) %) idx)) ; diagonal 1 (vector (map #((m (- 2 %)) %) idx)))) ; diagonal 2 (map (fn [row] (count (filter #(= player %) row)))) (filter #(= % 3)) seq)) -
fronx revised this gist
Sep 16, 2011 . 1 changed file with 9 additions and 12 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -4,16 +4,13 @@ (fn [m] (first (filter (fn win? [player] (->> (let [idx [0 1 2]] (concat m (map (fn [i] (map #(% i) m)) idx) (vector (map #((m %) %) idx)) (vector (map #((m (- 2 %)) %) idx)))) (map (fn [row] (count (filter #(= player %) row)))) (filter #(= % 3)) seq)) [:x :o]))) -
fronx revised this gist
Sep 16, 2011 . 1 changed file with 5 additions and 8 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -6,14 +6,11 @@ (filter (fn [p] (if (empty? (->> (let [idx '(0 1 2)] (concat m (map (fn [i] (map #(% i) m)) idx) (vector (map #((m %) %) idx)) (vector (map #((m (- 2 %)) %) idx)))) (map (fn [row] (count (filter #(= p %) row)))) (filter #(= % 3)))) -
There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,22 @@ ;; 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])))