Created
January 16, 2018 23:42
-
-
Save omartell/382b64acdebbc502ebcfc6d3c35b4971 to your computer and use it in GitHub Desktop.
Sudoku Check
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
(defn sudokuCheck [rows] | |
(let [digits (set (range 1 10)) | |
all-digits? (fn [col] | |
(every? (comp empty? #(clojure.set/difference digits (set %))) | |
col)) | |
columns (for [index (range 0 9)] | |
(for [row rows] | |
(get row index))) | |
squares (for [gx (partition 3 (range 0 9)) | |
gy (partition 3 (range 0 9))] | |
(for [x gx | |
y gy] | |
(get-in rows [x y])))] | |
(and (all-digits? rows) | |
(all-digits? columns) | |
(all-digits? squares)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment