~willvaughn/kata

3451ba08f98a58abd0fe8c6e9fcb311c77ab53ea — William Vaughn 1 year, 4 months ago f2ab8b5
refactor codewars sudoku minorly
1 files changed, 5 insertions(+), 7 deletions(-)

M codewars/src/clj/org/willvaughn/codewars/sudoku.clj
M codewars/src/clj/org/willvaughn/codewars/sudoku.clj => codewars/src/clj/org/willvaughn/codewars/sudoku.clj +5 -7
@@ 33,10 33,10 @@
;;;   [3, 0, 0, 4, 8, 1, 1, 7, 9]
;;; ]); // => false

(defn valid-set? [column]
  (and (= 1 (apply min column))
       (= 9 (apply max column))
       (= 9 (count (distinct column)))))
(defn valid-group? [group]
  (and (= 1 (apply min group))
       (= 9 (apply max group))
       (= 9 (count (distinct group)))))

(defn board->columns [board]
  (map (fn [col]


@@ 54,6 54,4 @@
(defn valid-solution [board]
  (let [columns (board->columns board)
        blocks (board->blocks board)]
    (and (every? valid-set? board)
         (every? valid-set? columns)
         (every? valid-set? blocks))))
    (every? valid-group? (concat board columns blocks))))