-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexamples2.py
More file actions
138 lines (125 loc) · 4.5 KB
/
Copy pathexamples2.py
File metadata and controls
138 lines (125 loc) · 4.5 KB
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
from gridsolver.abstract_grids.grid import Grid
from gridsolver.abstract_grids.grid_loading import create_from_str
from gridsolver.grid_classes.killer_sudoku import KillerSudoku
from gridsolver.grid_classes.sudoku import Sudoku
def get_example(args) -> Grid:
# "s"/"f"/"m" are the same puzzles the Examples package defines; import
# them instead of duplicating the definitions (drift risk). Lazy imports
# keep unrelated example choices from paying construction cost.
if args.example == "s":
from Examples import exampleSudoku
g = exampleSudoku.g
elif args.example == "t":
g = Sudoku()
g.load(
[[8, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 3, 6, 0, 0, 0, 0, 0], [0, 7, 0, 0, 9, 0, 2, 0, 0],
[0, 5, 0, 0, 0, 7, 0, 0, 0],
[0, 0, 0, 0, 4, 5, 7, 0, 0], [0, 0, 0, 1, 0, 0, 0, 3, 0], [0, 0, 1, 0, 0, 0, 0, 6, 8],
[0, 0, 8, 5, 0, 0, 0, 1, 0],
[0, 9, 0, 0, 0, 0, 4, 0, 0]], row_wise=True)
elif args.example == "f":
from Examples import exampleFutoshiki
g = exampleFutoshiki.g
elif args.example == "b":
g = KillerSudoku()
g.ext_sum_cells([
(22, (0, 0, 0, 1, 1, 1, 1, 2)),
(10, (1, 0, 2, 0, 3, 0)),
(5, (4, 0, 4, 1)),
(17, (5, 0, 6, 0, 7, 0)),
(29, (2, 1, 3, 1, 3, 2, 3, 3)),
(14, (5, 1, 5, 2)),
(24, (6, 1, 6, 2, 6, 3, 6, 4)),
(14, (7, 1, 8, 1, 8, 0)),
(23, (0, 2, 0, 3, 0, 4, 1, 4)),
(28, (4, 2, 4, 3, 4, 4, 4, 5, 4, 6)),
(5, (7, 2, 8, 2)),
(13, (1, 3, 2, 3, 2, 2)),
(10, (5, 3, 5, 4)),
(5, (7, 3, 8, 3)),
(26, (2, 4, 2, 5, 2, 6, 2, 7)),
(7, (3, 4, 3, 5)),
(20, (7, 4, 8, 4, 8, 5, 8, 6)),
(11, (0, 5, 1, 5)),
(19, (5, 5, 5, 6, 5, 7, 6, 7)),
(11, (6, 5, 7, 5, 6, 6)),
(10, (0, 6, 1, 6)),
(6, (3, 6, 3, 7)),
(29, (7, 6, 7, 7, 8, 7, 8, 8)),
(14, (0, 7, 0, 8, 1, 7)),
(12, (4, 7, 4, 8)),
(9, (1, 8, 2, 8, 3, 8)),
(12, (5, 8, 6, 8, 7, 8))
])
elif args.example == "a":
g = KillerSudoku()
g.ext_sum_cells([
(29, (0, 0, 1, 0, 0, 1, 1, 1)),
(16, (0, 2, 1, 2, 2, 2, 2, 1, 2, 0)),
(15, (0, 3, 0, 4, 0, 5)),
(10, (0, 6, 0, 7, 0, 8)),
(17, (1, 3, 1, 4)),
(9, (1, 5, 1, 6, 1, 7)),
(11, (1, 8, 2, 8)),
(8, (2, 3, 2, 4)),
(4, (2, 5, 3, 5)),
(23, (2, 6, 2, 7, 3, 7)),
(7, (3, 0, 4, 0, 5, 0)),
(11, (3, 1, 4, 1)),
(14, (3, 2, 4, 2)),
(21, (3, 3, 3, 4, 4, 3, 4, 4)),
(8, (3, 6, 4, 6, 4, 7)),
(16, (3, 8, 4, 8)),
(26, (4, 5, 5, 5, 5, 4, 5, 6, 6, 5)),
(17, (5, 1, 6, 1, 7, 1)),
(16, (5, 2, 5, 3)),
(12, (5, 7, 5, 8)),
(17, (6, 0, 7, 0, 8, 0)),
(13, (6, 2, 7, 2, 7, 3)),
(7, (6, 3, 6, 4, 7, 4)),
(16, (6, 6, 7, 6, 8, 6)),
(13, (6, 7, 6, 8)),
(14, (7, 5, 8, 5)),
(11, (7, 7, 8, 7)),
(5, (7, 8, 8, 8)),
(9, (8, 1, 8, 2)),
(10, (8, 3, 8, 4)),
])
elif args.example == "c":
g = create_from_str(
"""
KillerSudoku::
aaabbbccc
defffgghi
dejkkklhi
dejjkllhi
mennnoohp
mqrrsttup
mqqrstuup
vvvwwwxxx
yyywwwzzz
:
a6b24c15d12e24f19g3h20i6j15k16l23m23n17o10p18q22r9s4t18u11v12w33x18y10z17
""")
elif args.example == "d":
g = KillerSudoku()
g.load_with_dic(
"""
aabbccdde
afbgchhde
ifjgkkhle
ifjjkmmln
oppqqmrln
oosqturvn
wwsttuxvv
wwyyyyxvv
zzzzy0011
""", {"a": 15, "b": 19, "c": 16, "d": 8, "e": 19, "f": 15, "g": 4, "h": 18,
"i": 7, "j": 16, "k": 16, "l": 12, "m": 17, "n": 17, "o": 17, "p": 10, "q": 20, "r": 7,
"s": 6, "t": 9, "u": 7, "v": 26, "w": 23, "x": 12, "y": 26, "z": 21, "0": 12, "1": 10})
elif args.example == "m":
from Examples import miracleSudoku
g = miracleSudoku.g
else:
raise ValueError("Example choice not supported: " + str(args.example))
return g