-
Notifications
You must be signed in to change notification settings - Fork 1
/
tests.py
160 lines (148 loc) · 10.3 KB
/
tests.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
import pygame
from src.solver import Solver
from src.file import decode
import time
SOLVER_TESTS = {
'3:Kw202200Fw62Dw4': '101100110',
'3:202Lw202Fw60Dw4': '101101100',
'3:022Mw200Fw60Dw4': '011100100',
'3:22Kw002Jw0Ew62Fw4': '110010110',
'3:Lw2022Lw02Fw6Fw42': '101101101',
'4:Fy22222Cw0Jw022Jw0Cw02222Fy2': '1111100110011111',
'4:Fw22220Cy0Jw200Jw2Cy00222Fw2': '1111001001001111',
'4:Dy62200Cy4Jy222Jy0Cy42220Dy6': '1110001110011101',
'4:Ay20Ay2Kw+EAy20Ay20Bw+CAy2': '1010000010100001',
'4:Jy222Jy2Ay422Ay4Ay422Ay4Ay622Ay6': '1111011001101111',
'4:Jy0Jy2Jy0Jy0Ay4Jy2Jy2Ay4Ay4Jy0Jy2Ay4Ay6Ay2Ay2Ay6': '0100011000101111',
'4:Ay4Jy0Ay6Jy2Ay6Jy2Ay4Jy0Ay4Jy0Ay6Jy2Ay6Jy2Ay4Jy0': '0011110000111100',
'4:Iy222Jy2Jy222Jy2Jy200Jy2Jy200Iy2': '1111111110011001',
'7:222+CAy2002Ey2Dk0Cb2Bk+DFw0220': '111000100110100000110',
'4:Py222Cy20Iy2+DIy20Cy222Py2': '1111010000101111',
'4:Ay20Ay2Jy0Jy020Jy0Jy0Jy0Ay2Jy0Jy+CJy0Jy0Ay20Iy0': '10100100001000000100',
'5:2By2Db0Cy2Eb+D200202002020Eb0Cy2Ab0By20': '1101000010010100101001010',
'4:Jy20Ab0Jw2Ay2022002Ay0Jb0Aw22Jy0': '1001101100100110',
'5:Br40Cr60Br4+ECr60Er40Cr6+EBr40Cr60Br4': '0111001010110110100001100',
'6:Ek4+DEk40Fw6+GDb4+LFw60Ek46+CEk0': '000000011100010010010010011110010000',
'4:W622W402202222W400W6': '1110011011110001',
'4:So40So0So222222200So60So2So6': '0001111111001011',
'5:2Sk00Sk2Sp6Sk040So4Sk+CSo2Sw20Sk2So4Sw2So20Sp2Sk0400': '1011100100111101011010000',
'5:22Sp2Sw4So42So020Sk62Sw02Sw02Sk602So02Sw4So4Sp222': '1110010101101011010100111',
'5:2So2So2So00So00So42So02So62So4So2So02So60So20So02So02': '1110000010111010110100101',
'4:Sb22Sb2So2So2Sb00So0So0So220So0So2So0Sb0': '1111100001100100',
'7:Tw62Tw00Tw2604224022': '11001100110011',
'8:20620026Tg06Tp6Tw2Tk026Tw620620026': '101100110111011110110011',
'6:220664Tw20Ty0Tw6Tk44220664': '110110100100110110',
'7:4602220Tw660Uw0Uw2Tw004602020': '010111011001000101010',
'5:0Uk660Uw066022200240Uk0244Uw220Uk42': '0110011011100100010011001',
'6:0602Uk222Tw62020020Tw002Uk00202Uk206Tw62422024Uk40': '010111111010010001001011011101101000',
'8:22200202200226Uk+CUk020Tw662026606Uk0020Tw266002002Uk00662020060Tw662026602Uk+CUk0Tw62200220200222': '11100101100111000010111011101001011100100100111010010111011101000011100110100111',
'4:V2V0V2V0V0V2V0V2V2V0V2V0V0V2V0V2': '1010010110100101',
'4:W2W2W0W0W0W0W2W2W2W2W0W0W0W0W2W2': '1100001111000011',
'4:X2X2X2X2X2X0X0X2X2X0X0X2X2X2X2X2': '1111100110011111',
'6:02Y2220W2V062Z2W2X220W020': '011110101111110010',
'5:Dp220Y+C2Dp20202Z220X002002W2Fy+C': '1100001101011100010011000',
'5:So22Sk00So4So22Sk60So2So02Sk00So2So42Sk60So0': '11000111010100101100',
'4:Sy22Sy002Z22Sy0Sy020Sy20Sy0Sy22': '1100111001010011',
'6:Sy22V022Sy62Z6202V0V02Sy0222200Sy2020020Z40Sy42V020Sy0': '110111111010010111100101001000010100',
'5:2222X22Sy02Z2220022220022Z2202Sp2220Sy0': '111111011110011110011110111100',
'6:Sy2222Sy0X02222X20200X02202X20220X22022X0Sy0200Sy0': '111100111110100011011011011011001000',
'6:222222220Sp222Sy202V02202Z22022Z22022220W222': '111111110111101011011101111011110111',
'6:Sk22222Sw22Sp622Sy40222W02020W2+C2Sp400Sy62Sw22222Sk2': '111111111100111010101000100011111111',
'5:Tp60Ty22+E2Ty2202Tp4': '101100000111010',
'8:Uy200Uy022Uy20Y2202Uy02002022002Uy0Uy+CUy20Uy222': '10001110110101001011001000010111',
'8:0W02002022X2V02+C2W0Y222Ty0V2+CTy6022022': '00100101110100010111010001011011',
'5:Ak2+C2022Fo2002Ak4202Co22Fp00Ak42002': '1000101110010101110001001',
'4:22Sk0Cp0So022Sk00Sk022Fk00So02': '1100011000110001',
'4:Dk222Sk00Sk02002Sk00Sk022Do2': '1110001001000111',
'4:Eo622So22So+D2So20So222Eo4': '1111100001101110',
'7:Ub2Uo2240Ub0Uw2': '1110001',
'11:260260260062Uw6Uy02Uk6Uw40Up6Uk40Uy606026006006': '110110110011101100100101011001001',
'11:62220022224Uy60Ub4Uy6Uw022Ub022Uw466220220244': '111100111101001011011011110110100',
'7:4602022Tw662Tw00Uw024602022': '010101111100010101011',
'10:To060020To20202Tp602Tp6006Tp6+C20Uw4Uw6200To2': '010010101011011001100010011001',
'10:22Uw4204Uw60222+D6622+C2Uw0264Uw202': '110100101110000111100010110101',
'5:2Sk22So00Sb2So02Sb2020So4So60So0Sk2So62So+DSo02': '1110010110100100111000001',
'6:222+CSp20Sp2Sp06Sp00To0Sk0Sk2To6202Sk0Sk202Sp2To6Sp2Sp0To0Sp0202020': '111000101010000111010101111000101010',
'5:Uo222So002So02So2So02+C2So022So020So022Uo2': '1110010110100010110100111',
'3:200Uo00Sk222So22So02So2002Sk2Uo0': '100001111101100110',
'5:Ey2Bk0Br22Ar220Bk002220Bk0Br22Ar020Bk00222Ey2': '1011110001110011010001111',
'6:8288Do282To202To20828828': '010010110110010010',
'6:8Bo288Bo082To2Bo2Bo0To00808828': '010000111000000010',
'6:8288To282To020Do00828808': '010010101000010000',
'6:8288Ck282Uk00Ck0208288Uk28': '010010100010010010',
'6:8Uk0882822Dk622Dk68288Uk08': '010000111111000010',
'6:4Uk24404Fk02222Fk04044Uk24': '010000011110000010',
'6:2To022Tp002Dk2Tp00202To020Ck22': '101100110010101011',
'5:To22002Dk2Tp20Tp02To002Ck2+C202': '11001110010011000101',
'4:02Sk02220To0Do20V600V6+CTo02Sk020220022Ho202022022222': '0101110010100100001010110011101011011111',
'6:-C2-DSk2028822Bw02Sk2Sk22Aw02282Bw022-C0Sk2-C': '000100001010011011110110101100001000',
'6:220020Ty00Ty220Uk00Sy02202220Uk0220020Sk022Uk00222': '110010001100001101110011001001100111',
'3:Cr22Cr22Sr022Sr+CSr22Cr00Cr2': '111101100011001',
'3:V2X+C4V2W220020W2Z2W2020': '100001110010111010',
'5:Ck2220Bw2022020Ak2Aw0Aw200220220Ck2Ck20': '1110101101010100110110110',
'5:Sy62Sy20Sy600Sy00Sy2Sy0Sy22Sy2Sy0Sy20Sy+CSy60Sy22Sy6': '1110100001011101000010111',
'5:Dy22Dp4Dk20Fk020220200200220022+CEp2Ey002': '110100101101001001100110001001',
'6:V02V022V02Z620X42V02V0V20220V2V02V02X402Z62V022V02V0': '010110111001010101101010100111011010',
'8:20022202066Tp62+D240Ty022222462Tp220224644Ty42202602220022022220202222': '1001110101111000010001111101111011010001101101110011011110101111',
'7:Sw06So40Sk0Sb6Sw40So4So0Sp+CSb+CSp0So6+DSk4+ESb+E6So4Sw6Sb4+CSo0Sw0': '110001010110101011010100001011111101000000',
'4:Ay4200202By2020Bb0By202Cw6202Cb00200Cb002By2': '0100101101001011101001000011',
'6:Ay222222Eb0By222220Db0Cy222200Cb0Dy222+CBb0Ey22+DAb0Fy2': '111111011111001111000111000011000001',
'7:Fp62Dk+C2Ey602220222020Aw60222Aw42+C2Bk42Aw422020Bk42Aw020Gy220Cb22Db2Gp4': '1100011011101110101011101000101011010010101101110',
'6:Dp6+DDy6+HAk6Ap0Ab+DAp0Ak60Cy+GDp6+DEk4': '100111100100101010110101101011110000',
'5:Bb+DCy00Bb0By+DGy0Bb6+EBb6+CBy60Cy0': '1110001000001110001001100',
'6:Dw6+CAw4Ey6Gk4+QFb60Cw4Ck6+DCk6Cw4+KAw600Ak4+ECw60Gy4Bw0Gb40': '111101000011111001110101100110011001001010100100010100110100',
'5:Jk2222Hk2Sk0Sw20Sw20Sw0Sk02Sw0Sw0Sk2Sw00Sk20Hw2222Jw2': '1111101010001001001011111',
'6:Sk620-C0Tw62208Sk22Sk4028002Tw+C82Sk0022': '110000011100110010001000010011',
'6:0Sy00Ak00Cp0Sy0Ck0Sy0Cp0Sw4Sr00Sy+FSr6Dp00Sy+DSw6Sy00Sy0Ak0Jk0Sw0Sw6Sy0Dp0': '010001110101000111011100001100100111',
'6:Sk4+DSk0Ep0V+CBp00Ey+CCy+EDy+CDp00Dp+CZ0Dy0Sw+ESw6': '000110010000101110111010101111100011',
'8:88Ip0-GUr+D-C+EUr0Ik0800Sy0Sw+C8800Sk0Sp+C8Iw0Ur+F-C+CUr0-GIy088': '0010000000111100000001000011010000101100001000000011110000000100',
'5:0Uk6Uw6Tk00Uw22002': '0110011001',
'8:+FTk+CTk446Tw60Tw+J': '111011001001100100100111',
'5:0Uk0Uw0Uk00Uw+EUk0Uw+CUk+F': '11010100110110000101',
'4:2Sy2222X20Sk2Sk20X0222Sp2V0': '1111110110011110',
}
HARD_TESTS = {
'10:+CCk4Dw6Ck4Dw6Ck400Aw60Ck4+NEy+DIw40By4+EDb6+HAk4+KCb4+CAw6+FAw6+DAw6+FIb6+DIk6+FAw600Fb40': '0100101001100010110101011010100010010011100110010111000111100010100110010100101010111000101111010100',
'8:0Up0By+HAy4+DFb+SCb+GAy+CUp0Ab00Dy0Cb+EBy40Hb0': '01001111010101011111101010000110011000101010111011010011',
'6:20Tk0So20022022220To220Tk02+C20To002222': '100100010111101100100010001101',
'7:X2202Tp0222Tb+C2Uy0202060Z+DTp2V02+ETb2Z220V2Uy020202': '110101110001010101000001010000011101010101',
'9:+KW+DX+LX+DUy+HUy0V4Uy+GV0Uy+GW0W+IV+DX+CW+CY+E': '011111100010110111110111001101010111111101111111010101100111011111011010001111110',
'7:Sw0Sw+GSw60Sk+FSo0Sw6+ESw60Sw6+ESw6So+DSw00Sw00Sw+DSk6Sk0Sk600': '0011111111000110011011010101101100110000111110111',
'7:+FEb6+NAb600Hk400Ib6+G4+E4Bk44+C4Bk4': '1111111100000110111011010101101010101101100000000',
'10:Uo6Sk6So0Sp0So+CSo0So00So00So0So0So+ESo+DSp0So0So00So00So0So0Sp+JSo+ESo00So0So0So+OSo+DSo0So00So0So00So00So+HSo0So+CSo+DSo0Sp+DSk0Uo6': '1101010001010101111001011000100110011111101011010000101101011111100110010001101001111010100000100011',
'8:Uw0Sk0So+FSk+CBw00Bw+CCw+EAw+GSw6+FSw44+QSo0Sk4+DBw00Sk6Uw6': '0001000011010110010001000111100101100001110111011001010011110111',
'8:Sw0Sy0Sw0Jw0Jw00Jw+CJw+DY+CSw00Sw+FJw+CV0Jw0Sw4+CSw0Y0Iw0V+ISy+FY0Sw00Jw00Sw+CJw+DJw0': '0101101101010001010111111110100100110101011010010100001101111111',
'8:+FY+CUw+D40Dw+GTk+CDy4+GUy+CDy00Z06Dw0V00Cw+EY0Uw+CTk+EW00Y+DUy0': '0100111100011010011101001000001010110111010010100001001001111011',
'8:+CTw00Tk+CX+ITb00Uy+ETw+CZ6+CX+GSk+LSw+EUy00Tb+CTk+CSk0': '0010110100100010100110000111101100010101110001011101100001100100',
}
solver = Solver()
solver.SOLUTION_LIMIT = 1
pygame.init()
screen = pygame.display.set_mode((100, 100), pygame.RESIZABLE)
def run():
begin = time.time()
for i, (test, answer) in enumerate(SOLVER_TESTS.items()):
#for i, (test, answer) in enumerate(HARD_TESTS.items()):
i += 1
grid = decode(test)
width, height = len(grid[0]), len(grid)
if len(answer) != width*height:
print("ANSWER", i, "FAIL! Size is", len(answer), "when should be", width, "X", height, test)
return
solver.solve(grid)
for i2, n in enumerate(answer):
x, y = i2 // width, i2 % width
if grid[x][y].lit == None:
print("FAIL! Failed to solve puzzle", i, test)
return
if int(grid[x][y].lit) != int(n):
print("FAIL! Wrong answer for puzzle", i, test)
return
print("Test", i, "passed")
print("All tests PASSED!")
end = time.time()
print("Total elapsed time:", end - begin, "s")
#solver.solve(decode('6:0Sy00Ak00Cp0Sy0Ck0Sy0Cp0Sw4Sr00Sy+FSr6Dp00Sy+DSw6Sy00Sy0Ak0Jk0Sw0Sw6Sy0Dp0'))
run()
input()
'010001110101000111011100001100100111'