Commit dc2a34b 1 parent 98e91bc commit dc2a34b Copy full SHA for dc2a34b
File tree 1 file changed +16
-4
lines changed
1 file changed +16
-4
lines changed Original file line number Diff line number Diff line change 1
1
(ns musab.sudoku-test
2
2
(:require [clojure.test :refer :all ]
3
- [musab.sudoku :refer [solve solve-new]]))
3
+ [musab.sudoku :refer [format-board search parse-board-state]]
4
+ [musab.brute-force :refer [solve]]))
4
5
5
6
(def default-boards
6
7
{:1 {:board [[0 0 0 1 0 6 0 0 0 ]
50
51
[3 4 5 2 8 6 1 7 9 ]]}})
51
52
52
53
(deftest a-test
53
- (testing " Tests two examples."
54
+ (testing " Tests both algorithms."
55
+ ; ; Test bruteforce
54
56
(is (=
55
- (mapv vec (first (solve-new (get-in default-boards [:1 :board ]))))
57
+ (mapv vec (first (solve (get-in default-boards [:1 :board ]))))
56
58
(get-in default-boards [:1 :solution ])))
57
59
58
60
(is (=
59
- (mapv vec (first (solve-new (get-in default-boards [:2 :board ]))))
61
+ (mapv vec (first (solve (get-in default-boards [:2 :board ]))))
62
+ (get-in default-boards [:2 :solution ])))
63
+ ; ; Test Norvig CP
64
+ (is (=
65
+ (format-board (search
66
+ (parse-board-state (get-in default-boards [:1 :board ]))))
67
+ (get-in default-boards [:1 :solution ])))
68
+
69
+ (is (=
70
+ (format-board (search
71
+ (parse-board-state (get-in default-boards [:2 :board ]))))
60
72
(get-in default-boards [:2 :solution ])))))
You can’t perform that action at this time.
0 commit comments