Last active
July 24, 2023 17:25
-
-
Save camsaul/018fccd5c545b46a52f1f15e455bf63c to your computer and use it in GitHub Desktop.
Sudoku Board for testing purposes
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
(ns sudoku.core | |
(:require [clojure.test :refer :all])) | |
;; sample correctly-solved board | |
(def solved-board | |
[[5 3 4 6 7 8 9 1 2] | |
[6 7 2 1 9 5 3 4 8] | |
[1 9 8 3 4 2 5 6 7] | |
[8 5 9 7 6 1 4 2 3] | |
[4 2 6 8 5 3 7 9 1] | |
[7 1 3 9 2 4 8 5 6] | |
[9 6 1 5 3 7 2 8 4] | |
[2 8 7 4 1 9 6 3 5] | |
[3 4 5 2 8 6 1 7 9]]) | |
;; create a copy of the board with the number in 2,2 changed to 3 | |
(def bad-board | |
(assoc-in solved-board [2 2] 3)) | |
(defn solved? [board]) | |
(deftest solved-test | |
;; a correct board should return truthy | |
(is (solved? solved-board)) | |
;; an incorrect board should return falsey | |
(is (not (solved? bad-board)))) |
Common Lisp friendly
(defvar solved-board
'((5 3 4 6 7 8 9 1 2)
(6 7 2 1 9 5 3 4 8)
(1 9 8 3 4 2 5 6 7)
(8 5 9 7 6 1 4 2 3)
(4 2 6 8 5 3 7 9 1)
(7 1 3 9 2 4 8 5 6)
(9 6 1 5 3 7 2 8 4)
(2 8 7 4 1 9 6 3 5)
(3 4 5 2 8 6 1 7 9)))
(defvar bad-board
'((5 3 4 6 7 8 9 1 2)
(6 7 2 1 9 5 3 4 5)
(1 9 8 3 4 2 5 6 7)
(8 5 9 7 6 1 4 2 3)
(4 2 6 8 5 3 7 9 1)
(7 1 3 9 2 4 8 5 6)
(9 6 1 5 3 7 2 8 4)
(2 8 7 4 1 9 6 3 5)
(3 4 5 2 8 6 1 7 9)))
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Python/JS-friendly version of the board: