Permalink
Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
43 lines (30 sloc) 4.7 KB
(ns tests
(:use algorithm)
(:use [clojure.test :only (deftest are run-tests)]))
(deftest tests
(are [x y] (= x y)
(count squares)
81
(count unitlist)
27
(every? #(= 3 (count (units %))) squares)
true
(every? #(= 20 (count (peers %))) squares)
true
(units "C2")
[["A2" "B2" "C2" "D2" "E2" "F2" "G2" "H2" "I2"]
["C1" "C2" "C3" "C4" "C5" "C6" "C7" "C8" "C9"]
["A1" "A2" "A3" "B1" "B2" "B3" "C1" "C2" "C3"]]
(peers "C2")
#{"A2" "B2" "D2" "E2" "F2" "G2" "H2" "I2"
"C1" "C3" "C4" "C5" "C6" "C7" "C8" "C9"
"A1" "A3" "B1" "B3"}
@(solve-file "airplane_puzzle.txt")
{"I1" #{\7}, "H1" #{\9}, "I2" #{\1}, "G1" #{\5}, "H2" #{\8}, "I3" #{\6}, "F1" #{\3}, "G2" #{\2}, "H3" #{\3}, "I4" #{\2}, "E1" #{\2}, "F2" #{\9}, "G3" #{\4}, "H4" #{\1}, "I5" #{\3}, "D1" #{\4}, "E2" #{\6}, "F3" #{\8}, "G4" #{\6}, "H5" #{\7}, "I6" #{\4}, "C1" #{\6}, "D2" #{\7}, "E3" #{\5}, "F4" #{\7}, "G5" #{\9}, "H6" #{\5}, "I7" #{\5}, "B1" #{\1}, "C2" #{\4}, "D3" #{\1}, "E4" #{\4}, "F5" #{\6}, "G6" #{\8}, "H7" #{\4}, "I8" #{\8}, "A1" #{\8}, "B2" #{\3}, "C3" #{\7}, "D4" #{\5}, "E5" #{\8}, "F6" #{\1}, "G7" #{\1}, "H8" #{\2}, "I9" #{\9}, "A2" #{\5}, "B3" #{\9}, "C4" #{\3}, "D5" #{\2}, "E6" #{\3}, "F7" #{\2}, "G8" #{\3}, "H9" #{\6}, "A3" #{\2}, "B4" #{\8}, "C5" #{\1}, "D6" #{\9}, "E7" #{\9}, "F8" #{\5}, "G9" #{\7}, "A4" #{\9}, "B5" #{\5}, "C6" #{\2}, "D7" #{\3}, "E8" #{\7}, "F9" #{\4}, "A5" #{\4}, "B6" #{\6}, "C7" #{\8}, "D8" #{\6}, "E9" #{\1}, "A6" #{\7}, "B7" #{\7}, "C8" #{\9}, "D9" #{\8}, "A7" #{\6}, "B8" #{\4}, "C9" #{\5}, "A8" #{\1}, "B9" #{\2}, "A9" #{\3}}
@(solve-file "easy_puzzle.txt")
{"I1" #{\6}, "H1" #{\8}, "I2" #{\9}, "G1" #{\3}, "H2" #{\1}, "I3" #{\5}, "F1" #{\1}, "G2" #{\7}, "H3" #{\4}, "I4" #{\4}, "E1" #{\7}, "F2" #{\3}, "G3" #{\2}, "H4" #{\2}, "I5" #{\1}, "D1" #{\5}, "E2" #{\2}, "F3" #{\6}, "G4" #{\6}, "H5" #{\5}, "I6" #{\7}, "C1" #{\2}, "D2" #{\4}, "E3" #{\9}, "F4" #{\7}, "G5" #{\8}, "H6" #{\3}, "I7" #{\3}, "B1" #{\9}, "C2" #{\5}, "D3" #{\8}, "E4" #{\5}, "F5" #{\9}, "G6" #{\9}, "H7" #{\7}, "I8" #{\8}, "A1" #{\4}, "B2" #{\6}, "C3" #{\1}, "D4" #{\1}, "E5" #{\6}, "F6" #{\8}, "G7" #{\5}, "H8" #{\6}, "I9" #{\2}, "A2" #{\8}, "B3" #{\7}, "C4" #{\8}, "D5" #{\3}, "E6" #{\4}, "F7" #{\2}, "G8" #{\1}, "H9" #{\9}, "A3" #{\3}, "B4" #{\3}, "C5" #{\7}, "D6" #{\2}, "E7" #{\1}, "F8" #{\4}, "G9" #{\4}, "A4" #{\9}, "B5" #{\4}, "C6" #{\6}, "D7" #{\9}, "E8" #{\3}, "F9" #{\5}, "A5" #{\2}, "B6" #{\5}, "C7" #{\4}, "D8" #{\7}, "E9" #{\8}, "A6" #{\1}, "B7" #{\8}, "C8" #{\9}, "D9" #{\6}, "A7" #{\6}, "B8" #{\2}, "C9" #{\3}, "A8" #{\5}, "B9" #{\1}, "A9" #{\7}}
@(solve-file "hard_puzzle.txt")
{"I1" #{\1}, "H1" #{\5}, "I2" #{\6}, "G1" #{\2}, "H2" #{\7}, "I3" #{\4}, "F1" #{\3}, "G2" #{\8}, "H3" #{\3}, "I4" #{\8}, "E1" #{\7}, "F2" #{\4}, "G3" #{\9}, "H4" #{\2}, "I5" #{\7}, "D1" #{\8}, "E2" #{\9}, "F3" #{\6}, "G4" #{\6}, "H5" #{\9}, "I6" #{\5}, "C1" #{\9}, "D2" #{\2}, "E3" #{\1}, "F4" #{\9}, "G5" #{\4}, "H6" #{\1}, "I7" #{\2}, "B1" #{\6}, "C2" #{\5}, "D3" #{\5}, "E4" #{\5}, "F5" #{\1}, "G6" #{\3}, "H7" #{\6}, "I8" #{\9}, "A1" #{\4}, "B2" #{\3}, "C3" #{\8}, "D4" #{\4}, "E5" #{\8}, "F6" #{\2}, "G7" #{\5}, "H8" #{\8}, "I9" #{\3}, "A2" #{\1}, "B3" #{\2}, "C4" #{\7}, "D5" #{\3}, "E6" #{\6}, "F7" #{\7}, "G8" #{\7}, "H9" #{\4}, "A3" #{\7}, "B4" #{\1}, "C5" #{\2}, "D6" #{\7}, "E7" #{\4}, "F8" #{\5}, "G9" #{\1}, "A4" #{\3}, "B5" #{\5}, "C6" #{\4}, "D7" #{\1}, "E8" #{\3}, "F9" #{\8}, "A5" #{\6}, "B6" #{\8}, "C7" #{\3}, "D8" #{\6}, "E9" #{\2}, "A6" #{\9}, "B7" #{\9}, "C8" #{\1}, "D9" #{\9}, "A7" #{\8}, "B8" #{\4}, "C9" #{\6}, "A8" #{\2}, "B9" #{\7}, "A9" #{\5}}
@(solve-file "harder_puzzle.txt")
{"I1" #{\3}, "H1" #{\2}, "I2" #{\5}, "G1" #{\4}, "H2" #{\8}, "I3" #{\1}, "F1" #{\1}, "G2" #{\6}, "H3" #{\7}, "I4" #{\9}, "E1" #{\5}, "F2" #{\3}, "G3" #{\9}, "H4" #{\3}, "I5" #{\4}, "D1" #{\7}, "E2" #{\2}, "F3" #{\4}, "G4" #{\1}, "H5" #{\5}, "I6" #{\7}, "C1" #{\8}, "D2" #{\9}, "E3" #{\6}, "F4" #{\5}, "G5" #{\2}, "H6" #{\6}, "I7" #{\6}, "B1" #{\9}, "C2" #{\4}, "D3" #{\8}, "E4" #{\4}, "F5" #{\8}, "G6" #{\8}, "H7" #{\1}, "I8" #{\2}, "A1" #{\6}, "B2" #{\1}, "C3" #{\5}, "D4" #{\2}, "E5" #{\7}, "F6" #{\9}, "G7" #{\7}, "H8" #{\4}, "I9" #{\8}, "A2" #{\7}, "B3" #{\2}, "C4" #{\6}, "D5" #{\6}, "E6" #{\3}, "F7" #{\2}, "G8" #{\3}, "H9" #{\9}, "A3" #{\3}, "B4" #{\7}, "C5" #{\1}, "D6" #{\1}, "E7" #{\8}, "F8" #{\6}, "G9" #{\5}, "A4" #{\8}, "B5" #{\3}, "C6" #{\2}, "D7" #{\3}, "E8" #{\9}, "F9" #{\7}, "A5" #{\9}, "B6" #{\5}, "C7" #{\9}, "D8" #{\5}, "E9" #{\1}, "A6" #{\4}, "B7" #{\4}, "C8" #{\7}, "D9" #{\4}, "A7" #{\5}, "B8" #{\8}, "C9" #{\3}, "A8" #{\1}, "B9" #{\6}, "A9" #{\2}}))
(run-tests)