multi-puzzle-solver 1.1.8__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- multi_puzzle_solver-1.1.8.dist-info/METADATA +4326 -0
- multi_puzzle_solver-1.1.8.dist-info/RECORD +106 -0
- multi_puzzle_solver-1.1.8.dist-info/WHEEL +5 -0
- multi_puzzle_solver-1.1.8.dist-info/top_level.txt +1 -0
- puzzle_solver/__init__.py +184 -0
- puzzle_solver/core/utils.py +298 -0
- puzzle_solver/core/utils_ortools.py +333 -0
- puzzle_solver/core/utils_visualizer.py +575 -0
- puzzle_solver/puzzles/abc_view/abc_view.py +75 -0
- puzzle_solver/puzzles/aquarium/aquarium.py +97 -0
- puzzle_solver/puzzles/area_51/area_51.py +159 -0
- puzzle_solver/puzzles/battleships/battleships.py +139 -0
- puzzle_solver/puzzles/binairo/binairo.py +98 -0
- puzzle_solver/puzzles/binairo/binairo_plus.py +7 -0
- puzzle_solver/puzzles/black_box/black_box.py +243 -0
- puzzle_solver/puzzles/branches/branches.py +64 -0
- puzzle_solver/puzzles/bridges/bridges.py +104 -0
- puzzle_solver/puzzles/chess_range/chess_melee.py +6 -0
- puzzle_solver/puzzles/chess_range/chess_range.py +406 -0
- puzzle_solver/puzzles/chess_range/chess_solo.py +9 -0
- puzzle_solver/puzzles/chess_sequence/chess_sequence.py +262 -0
- puzzle_solver/puzzles/circle_9/circle_9.py +44 -0
- puzzle_solver/puzzles/clouds/clouds.py +81 -0
- puzzle_solver/puzzles/connect_the_dots/connect_the_dots.py +50 -0
- puzzle_solver/puzzles/cow_and_cactus/cow_and_cactus.py +66 -0
- puzzle_solver/puzzles/dominosa/dominosa.py +67 -0
- puzzle_solver/puzzles/filling/filling.py +94 -0
- puzzle_solver/puzzles/flip/flip.py +64 -0
- puzzle_solver/puzzles/flood_it/flood_it.py +174 -0
- puzzle_solver/puzzles/flood_it/parse_map/parse_map.py +197 -0
- puzzle_solver/puzzles/galaxies/galaxies.py +110 -0
- puzzle_solver/puzzles/galaxies/parse_map/parse_map.py +216 -0
- puzzle_solver/puzzles/guess/guess.py +232 -0
- puzzle_solver/puzzles/heyawake/heyawake.py +152 -0
- puzzle_solver/puzzles/hidden_stars/hidden_stars.py +52 -0
- puzzle_solver/puzzles/hidoku/hidoku.py +59 -0
- puzzle_solver/puzzles/inertia/inertia.py +121 -0
- puzzle_solver/puzzles/inertia/parse_map/parse_map.py +207 -0
- puzzle_solver/puzzles/inertia/tsp.py +400 -0
- puzzle_solver/puzzles/kakurasu/kakurasu.py +38 -0
- puzzle_solver/puzzles/kakuro/kakuro.py +81 -0
- puzzle_solver/puzzles/kakuro/krypto_kakuro.py +95 -0
- puzzle_solver/puzzles/keen/keen.py +76 -0
- puzzle_solver/puzzles/kropki/kropki.py +94 -0
- puzzle_solver/puzzles/light_up/light_up.py +58 -0
- puzzle_solver/puzzles/linesweeper/linesweeper.py +71 -0
- puzzle_solver/puzzles/link_a_pix/link_a_pix.py +91 -0
- puzzle_solver/puzzles/lits/lits.py +138 -0
- puzzle_solver/puzzles/magnets/magnets.py +96 -0
- puzzle_solver/puzzles/map/map.py +56 -0
- puzzle_solver/puzzles/mathema_grids/mathema_grids.py +119 -0
- puzzle_solver/puzzles/mathrax/mathrax.py +93 -0
- puzzle_solver/puzzles/minesweeper/minesweeper.py +123 -0
- puzzle_solver/puzzles/mosaic/mosaic.py +38 -0
- puzzle_solver/puzzles/n_queens/n_queens.py +71 -0
- puzzle_solver/puzzles/nonograms/nonograms.py +121 -0
- puzzle_solver/puzzles/nonograms/nonograms_colored.py +220 -0
- puzzle_solver/puzzles/norinori/norinori.py +96 -0
- puzzle_solver/puzzles/number_path/number_path.py +76 -0
- puzzle_solver/puzzles/numbermaze/numbermaze.py +97 -0
- puzzle_solver/puzzles/nurikabe/nurikabe.py +130 -0
- puzzle_solver/puzzles/palisade/palisade.py +91 -0
- puzzle_solver/puzzles/pearl/pearl.py +107 -0
- puzzle_solver/puzzles/pipes/pipes.py +82 -0
- puzzle_solver/puzzles/range/range.py +59 -0
- puzzle_solver/puzzles/rectangles/rectangles.py +128 -0
- puzzle_solver/puzzles/ripple_effect/ripple_effect.py +83 -0
- puzzle_solver/puzzles/rooms/rooms.py +75 -0
- puzzle_solver/puzzles/schurs_numbers/schurs_numbers.py +73 -0
- puzzle_solver/puzzles/shakashaka/shakashaka.py +201 -0
- puzzle_solver/puzzles/shingoki/shingoki.py +116 -0
- puzzle_solver/puzzles/signpost/signpost.py +93 -0
- puzzle_solver/puzzles/singles/singles.py +53 -0
- puzzle_solver/puzzles/slant/parse_map/parse_map.py +135 -0
- puzzle_solver/puzzles/slant/slant.py +111 -0
- puzzle_solver/puzzles/slitherlink/slitherlink.py +130 -0
- puzzle_solver/puzzles/snail/snail.py +97 -0
- puzzle_solver/puzzles/split_ends/split_ends.py +93 -0
- puzzle_solver/puzzles/star_battle/star_battle.py +75 -0
- puzzle_solver/puzzles/star_battle/star_battle_shapeless.py +7 -0
- puzzle_solver/puzzles/stitches/parse_map/parse_map.py +267 -0
- puzzle_solver/puzzles/stitches/stitches.py +96 -0
- puzzle_solver/puzzles/sudoku/sudoku.py +267 -0
- puzzle_solver/puzzles/suguru/suguru.py +55 -0
- puzzle_solver/puzzles/suko/suko.py +54 -0
- puzzle_solver/puzzles/tapa/tapa.py +97 -0
- puzzle_solver/puzzles/tatami/tatami.py +64 -0
- puzzle_solver/puzzles/tents/tents.py +80 -0
- puzzle_solver/puzzles/thermometers/thermometers.py +82 -0
- puzzle_solver/puzzles/towers/towers.py +89 -0
- puzzle_solver/puzzles/tracks/tracks.py +88 -0
- puzzle_solver/puzzles/trees_logic/trees_logic.py +48 -0
- puzzle_solver/puzzles/troix/dumplings.py +7 -0
- puzzle_solver/puzzles/troix/troix.py +75 -0
- puzzle_solver/puzzles/twiddle/twiddle.py +112 -0
- puzzle_solver/puzzles/undead/undead.py +130 -0
- puzzle_solver/puzzles/unequal/unequal.py +128 -0
- puzzle_solver/puzzles/unruly/unruly.py +54 -0
- puzzle_solver/puzzles/vectors/vectors.py +94 -0
- puzzle_solver/puzzles/vermicelli/vermicelli.py +74 -0
- puzzle_solver/puzzles/walls/walls.py +52 -0
- puzzle_solver/puzzles/yajilin/yajilin.py +87 -0
- puzzle_solver/puzzles/yin_yang/parse_map/parse_map.py +172 -0
- puzzle_solver/puzzles/yin_yang/yin_yang.py +103 -0
- puzzle_solver/utils/etc/parser/board_color_digit.py +497 -0
- puzzle_solver/utils/visualizer.py +155 -0
|
@@ -0,0 +1,4326 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: multi-puzzle-solver
|
|
3
|
+
Version: 1.1.8
|
|
4
|
+
Summary: Efficient solvers for countless (85+) types of puzzles (like Sudoku, Minesweeper, etc.) with a simple python API.
|
|
5
|
+
Author: Ar-Kareem
|
|
6
|
+
Project-URL: Homepage, https://github.com/Ar-Kareem/puzzle_solver
|
|
7
|
+
Project-URL: Repository, https://github.com/Ar-Kareem/puzzle_solver
|
|
8
|
+
Project-URL: Issues, https://github.com/Ar-Kareem/puzzle_solver/issues
|
|
9
|
+
Keywords: puzzle,solver,sat,cp-sat,google-or-tools,efficient,logic,puzzle-solver,puzzle-solver-python,sudoku,nonograms,minesweeper,dominosa,lightup,map,inertia,tents,towers,tracks,undead,unruly,bridges,pearl,range,signpost,singles,magnets
|
|
10
|
+
Classifier: Development Status :: 4 - Beta
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: Intended Audience :: Education
|
|
13
|
+
Classifier: Intended Audience :: Science/Research
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
19
|
+
Requires-Python: >=3.9
|
|
20
|
+
Description-Content-Type: text/markdown
|
|
21
|
+
Requires-Dist: numpy
|
|
22
|
+
Requires-Dist: ortools
|
|
23
|
+
Provides-Extra: dev
|
|
24
|
+
Requires-Dist: pytest; extra == "dev"
|
|
25
|
+
Requires-Dist: pytest-xdist; extra == "dev"
|
|
26
|
+
|
|
27
|
+
# Python Puzzle Solver
|
|
28
|
+
|
|
29
|
+
Solve countless (85+) classical logic puzzles automatically in Python.
|
|
30
|
+
|
|
31
|
+
Can also tell you if a partial puzzle has a single unique solution or not (and retrieves all possible solutions).
|
|
32
|
+
|
|
33
|
+
## Install
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
pip install multi-puzzle-solver
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
<div align="center">
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
## 🕹️ Puzzle Gallery
|
|
43
|
+
|
|
44
|
+
These are all the puzzles that are implemented in this repo. <br> Click on any of them to go to that Puzzle's README.
|
|
45
|
+
|
|
46
|
+
<table>
|
|
47
|
+
<!-- AUTO-GENERATED GALLERY START -->
|
|
48
|
+
|
|
49
|
+
<tr>
|
|
50
|
+
<td align="center">
|
|
51
|
+
<a href="https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/nonograms"><b>Nonograms</b><br><br>
|
|
52
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/nonogram_solved.png" alt="Nonograms" width="140">
|
|
53
|
+
</a>
|
|
54
|
+
</td>
|
|
55
|
+
<td align="center">
|
|
56
|
+
<a href="https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/sudoku"><b>Sudoku</b><br><br>
|
|
57
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/sudoku_solved.png" alt="Sudoku" width="140">
|
|
58
|
+
</a>
|
|
59
|
+
</td>
|
|
60
|
+
<td align="center">
|
|
61
|
+
<a href="https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/minesweeper"><b>Minesweeper</b><br><br>
|
|
62
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/minesweeper_pre.png" alt="Minesweeper" width="140">
|
|
63
|
+
</a>
|
|
64
|
+
</td>
|
|
65
|
+
<td align="center">
|
|
66
|
+
<a href="https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/dominosa"><b>Dominosa</b><br><br>
|
|
67
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/dominosa_solved.png" alt="Dominosa" width="140">
|
|
68
|
+
</a>
|
|
69
|
+
</td>
|
|
70
|
+
<td align="center">
|
|
71
|
+
<a href="https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/light_up"><b>Light Up</b><br><br>
|
|
72
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/lightup_solved.png" alt="Light Up" width="140">
|
|
73
|
+
</a>
|
|
74
|
+
</td>
|
|
75
|
+
</tr>
|
|
76
|
+
<tr>
|
|
77
|
+
<td align="center">
|
|
78
|
+
<a href="https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/tents"><b>Tents</b><br><br>
|
|
79
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/tents_solved.png" alt="Tents" width="140">
|
|
80
|
+
</a>
|
|
81
|
+
</td>
|
|
82
|
+
<td align="center">
|
|
83
|
+
<a href="https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/filling"><b>Filling</b><br><br>
|
|
84
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/filling_solved.png" alt="Filling" width="140">
|
|
85
|
+
</a>
|
|
86
|
+
</td>
|
|
87
|
+
<td align="center">
|
|
88
|
+
<a href="https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/keen"><b>Keen</b><br><br>
|
|
89
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/keen_solved.png" alt="Keen" width="140">
|
|
90
|
+
</a>
|
|
91
|
+
</td>
|
|
92
|
+
<td align="center">
|
|
93
|
+
<a href="https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/towers"><b>Towers</b><br><br>
|
|
94
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/towers_solved.png" alt="Towers" width="140">
|
|
95
|
+
</a>
|
|
96
|
+
</td>
|
|
97
|
+
<td align="center">
|
|
98
|
+
<a href="https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/singles"><b>Singles</b><br><br>
|
|
99
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/singles_solved.png" alt="Singles" width="140">
|
|
100
|
+
</a>
|
|
101
|
+
</td>
|
|
102
|
+
</tr>
|
|
103
|
+
<tr>
|
|
104
|
+
<td align="center">
|
|
105
|
+
<a href="https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/magnets"><b>Magnets</b><br><br>
|
|
106
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/magnets_solved.png" alt="Magnets" width="140">
|
|
107
|
+
</a>
|
|
108
|
+
</td>
|
|
109
|
+
<td align="center">
|
|
110
|
+
<a href="https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/signpost"><b>Signpost</b><br><br>
|
|
111
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/signpost_solved.png" alt="Signpost" width="140">
|
|
112
|
+
</a>
|
|
113
|
+
</td>
|
|
114
|
+
<td align="center">
|
|
115
|
+
<a href="https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/range"><b>Range</b><br><br>
|
|
116
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/range_solved.png" alt="Range" width="140">
|
|
117
|
+
</a>
|
|
118
|
+
</td>
|
|
119
|
+
<td align="center">
|
|
120
|
+
<a href="https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/undead"><b>Undead</b><br><br>
|
|
121
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/undead_solved.png" alt="Undead" width="140">
|
|
122
|
+
</a>
|
|
123
|
+
</td>
|
|
124
|
+
<td align="center">
|
|
125
|
+
<a href="https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/unruly"><b>Unruly</b><br><br>
|
|
126
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/unruly_solved.png" alt="Unruly" width="140">
|
|
127
|
+
</a>
|
|
128
|
+
</td>
|
|
129
|
+
</tr>
|
|
130
|
+
<tr>
|
|
131
|
+
<td align="center">
|
|
132
|
+
<a href="https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/tracks"><b>Tracks</b><br><br>
|
|
133
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/tracks_solved.png" alt="Tracks" width="140">
|
|
134
|
+
</a>
|
|
135
|
+
</td>
|
|
136
|
+
<td align="center">
|
|
137
|
+
<a href="https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/mosaic"><b>Mosaic</b><br><br>
|
|
138
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/mosaic_solved.png" alt="Mosaic" width="140">
|
|
139
|
+
</a>
|
|
140
|
+
</td>
|
|
141
|
+
<td align="center">
|
|
142
|
+
<a href="https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/map"><b>Map</b><br><br>
|
|
143
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/map_solved.png" alt="Map" width="140">
|
|
144
|
+
</a>
|
|
145
|
+
</td>
|
|
146
|
+
<td align="center">
|
|
147
|
+
<a href="https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/pearl"><b>Pearl</b><br><br>
|
|
148
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/pearl_solved.png" alt="Pearl" width="140">
|
|
149
|
+
</a>
|
|
150
|
+
</td>
|
|
151
|
+
<td align="center">
|
|
152
|
+
<a href="https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/bridges"><b>Bridges</b><br><br>
|
|
153
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/bridges_solved.png" alt="Bridges" width="140">
|
|
154
|
+
</a>
|
|
155
|
+
</td>
|
|
156
|
+
</tr>
|
|
157
|
+
<tr>
|
|
158
|
+
<td align="center">
|
|
159
|
+
<a href="https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/inertia"><b>Inertia</b><br><br>
|
|
160
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/inertia_unsolved.png" alt="Inertia" width="140">
|
|
161
|
+
</a>
|
|
162
|
+
</td>
|
|
163
|
+
<td align="center">
|
|
164
|
+
<a href="https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/guess"><b>Guess</b><br><br>
|
|
165
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/guess_3.png" alt="Guess" width="140">
|
|
166
|
+
</a>
|
|
167
|
+
</td>
|
|
168
|
+
<td align="center">
|
|
169
|
+
<a href="https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/chess_range"><b>Chess Range</b><br><br>
|
|
170
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/chess_range_unsolved.png" alt="Chess Range" width="140">
|
|
171
|
+
</a>
|
|
172
|
+
</td>
|
|
173
|
+
<td align="center">
|
|
174
|
+
<a href="https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/chess_range"><b>Chess Solo</b><br><br>
|
|
175
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/chess_solo_unsolved.png" alt="Chess Solo" width="140">
|
|
176
|
+
</a>
|
|
177
|
+
</td>
|
|
178
|
+
<td align="center">
|
|
179
|
+
<a href="https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/chess_range"><b>Chess Melee</b><br><br>
|
|
180
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/chess_melee_unsolved.png" alt="Chess Melee" width="140">
|
|
181
|
+
</a>
|
|
182
|
+
</td>
|
|
183
|
+
</tr>
|
|
184
|
+
<tr>
|
|
185
|
+
<td align="center">
|
|
186
|
+
<a href="https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/thermometers"><b>Thermometers</b><br><br>
|
|
187
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/thermometers_solved.png" alt="Thermometers" width="140">
|
|
188
|
+
</a>
|
|
189
|
+
</td>
|
|
190
|
+
<td align="center">
|
|
191
|
+
<a href="https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/aquarium"><b>Aquarium</b><br><br>
|
|
192
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/aquarium_solved.png" alt="Aquarium" width="140">
|
|
193
|
+
</a>
|
|
194
|
+
</td>
|
|
195
|
+
<td align="center">
|
|
196
|
+
<a href="https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/stitches"><b>Stitches</b><br><br>
|
|
197
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/stitches_solved.png" alt="Stitches" width="140">
|
|
198
|
+
</a>
|
|
199
|
+
</td>
|
|
200
|
+
<td align="center">
|
|
201
|
+
<a href="https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/battleships"><b>Battleships</b><br><br>
|
|
202
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/battleships_solved.png" alt="Battleships" width="140">
|
|
203
|
+
</a>
|
|
204
|
+
</td>
|
|
205
|
+
<td align="center">
|
|
206
|
+
<a href="https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/kakurasu"><b>Kakurasu</b><br><br>
|
|
207
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/kakurasu_solved.png" alt="Kakurasu" width="140">
|
|
208
|
+
</a>
|
|
209
|
+
</td>
|
|
210
|
+
</tr>
|
|
211
|
+
<tr>
|
|
212
|
+
<td align="center">
|
|
213
|
+
<a href="https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/star_battle"><b>Star Battle</b><br><br>
|
|
214
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/star_battle_solved.png" alt="Star Battle" width="140">
|
|
215
|
+
</a>
|
|
216
|
+
</td>
|
|
217
|
+
<td align="center">
|
|
218
|
+
<a href="https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/star_battle"><b>Star Battle Shapeless</b><br><br>
|
|
219
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/star_battle_shapeless_solved.png" alt="Star Battle Shapeless" width="140">
|
|
220
|
+
</a>
|
|
221
|
+
</td>
|
|
222
|
+
<td align="center">
|
|
223
|
+
<a href="https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/lits"><b>Lits</b><br><br>
|
|
224
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/lits_solved.png" alt="Lits" width="140">
|
|
225
|
+
</a>
|
|
226
|
+
</td>
|
|
227
|
+
<td align="center">
|
|
228
|
+
<a href="https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/black_box"><b>Black Box</b><br><br>
|
|
229
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/black_box_solved.png" alt="Black Box" width="140">
|
|
230
|
+
</a>
|
|
231
|
+
</td>
|
|
232
|
+
<td align="center">
|
|
233
|
+
<a href="https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/galaxies"><b>Galaxies</b><br><br>
|
|
234
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/galaxies_solved.png" alt="Galaxies" width="140">
|
|
235
|
+
</a>
|
|
236
|
+
</td>
|
|
237
|
+
</tr>
|
|
238
|
+
<tr>
|
|
239
|
+
<td align="center">
|
|
240
|
+
<a href="https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/slant"><b>Slant</b><br><br>
|
|
241
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/slant_solved.png" alt="Slant" width="140">
|
|
242
|
+
</a>
|
|
243
|
+
</td>
|
|
244
|
+
<td align="center">
|
|
245
|
+
<a href="https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/unequal"><b>Unequal</b><br><br>
|
|
246
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/unequal_solved.png" alt="Unequal" width="140">
|
|
247
|
+
</a>
|
|
248
|
+
</td>
|
|
249
|
+
<td align="center">
|
|
250
|
+
<a href="https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/norinori"><b>Norinori</b><br><br>
|
|
251
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/norinori_solved.png" alt="Norinori" width="140">
|
|
252
|
+
</a>
|
|
253
|
+
</td>
|
|
254
|
+
<td align="center">
|
|
255
|
+
<a href="https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/slitherlink"><b>Slitherlink</b><br><br>
|
|
256
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/slitherlink_solved.png" alt="Slitherlink" width="140">
|
|
257
|
+
</a>
|
|
258
|
+
</td>
|
|
259
|
+
<td align="center">
|
|
260
|
+
<a href="https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/yin_yang"><b>Yin-Yang</b><br><br>
|
|
261
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/yin_yang_solved.png" alt="Yin-Yang" width="140">
|
|
262
|
+
</a>
|
|
263
|
+
</td>
|
|
264
|
+
</tr>
|
|
265
|
+
<tr>
|
|
266
|
+
<td align="center">
|
|
267
|
+
<a href="https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/binairo"><b>Binairo</b><br><br>
|
|
268
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/binairo_solved.png" alt="Binairo" width="140">
|
|
269
|
+
</a>
|
|
270
|
+
</td>
|
|
271
|
+
<td align="center">
|
|
272
|
+
<a href="https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/rectangles"><b>Rectangles</b><br><br>
|
|
273
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/rectangles_solved.png" alt="Rectangles" width="140">
|
|
274
|
+
</a>
|
|
275
|
+
</td>
|
|
276
|
+
<td align="center">
|
|
277
|
+
<a href="https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/palisade"><b>Palisade</b><br><br>
|
|
278
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/palisade_solved.png" alt="Palisade" width="140">
|
|
279
|
+
</a>
|
|
280
|
+
</td>
|
|
281
|
+
<td align="center">
|
|
282
|
+
<a href="https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/flip"><b>Flip</b><br><br>
|
|
283
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/flip_unsolved.png" alt="Flip" width="140">
|
|
284
|
+
</a>
|
|
285
|
+
</td>
|
|
286
|
+
<td align="center">
|
|
287
|
+
<a href="https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/nurikabe"><b>Nurikabe</b><br><br>
|
|
288
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/nurikabe_solved.png" alt="Nurikabe" width="140">
|
|
289
|
+
</a>
|
|
290
|
+
</td>
|
|
291
|
+
</tr>
|
|
292
|
+
<tr>
|
|
293
|
+
<td align="center">
|
|
294
|
+
<a href="https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/heyawake"><b>Heyawake</b><br><br>
|
|
295
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/heyawake_solved.png" alt="Heyawake" width="140">
|
|
296
|
+
</a>
|
|
297
|
+
</td>
|
|
298
|
+
<td align="center">
|
|
299
|
+
<a href="https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/shingoki"><b>Shingoki</b><br><br>
|
|
300
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/shingoki_solved.png" alt="Shingoki" width="140">
|
|
301
|
+
</a>
|
|
302
|
+
</td>
|
|
303
|
+
<td align="center">
|
|
304
|
+
<a href="https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/tapa"><b>Tapa</b><br><br>
|
|
305
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/tapa_solved.png" alt="Tapa" width="140">
|
|
306
|
+
</a>
|
|
307
|
+
</td>
|
|
308
|
+
<td align="center">
|
|
309
|
+
<a href="https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/binairo"><b>Binairo Plus</b><br><br>
|
|
310
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/binairo_plus_solved.png" alt="Binairo Plus" width="140">
|
|
311
|
+
</a>
|
|
312
|
+
</td>
|
|
313
|
+
<td align="center">
|
|
314
|
+
<a href="https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/shakashaka"><b>Shakashaka</b><br><br>
|
|
315
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/shakashaka_solved.png" alt="Shakashaka" width="140">
|
|
316
|
+
</a>
|
|
317
|
+
</td>
|
|
318
|
+
</tr>
|
|
319
|
+
<tr>
|
|
320
|
+
<td align="center">
|
|
321
|
+
<a href="https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/kakuro"><b>Kakuro</b><br><br>
|
|
322
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/kakuro_solved.png" alt="Kakuro" width="140">
|
|
323
|
+
</a>
|
|
324
|
+
</td>
|
|
325
|
+
<td align="center">
|
|
326
|
+
<a href="https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/sudoku"><b>Sudoku Jigsaw</b><br><br>
|
|
327
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/sudoku_jigsaw_solved.png" alt="Sudoku Jigsaw" width="140">
|
|
328
|
+
</a>
|
|
329
|
+
</td>
|
|
330
|
+
<td align="center">
|
|
331
|
+
<a href="https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/sudoku"><b>Sudoku Killer</b><br><br>
|
|
332
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/sudoku_killer_solved.png" alt="Sudoku Killer" width="140">
|
|
333
|
+
</a>
|
|
334
|
+
</td>
|
|
335
|
+
<td align="center">
|
|
336
|
+
<a href="https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/flood_it"><b>Flood It</b><br><br>
|
|
337
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/flood_it_unsolved.png" alt="Flood It" width="140">
|
|
338
|
+
</a>
|
|
339
|
+
</td>
|
|
340
|
+
<td align="center">
|
|
341
|
+
<a href="https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/pipes"><b>Pipes</b><br><br>
|
|
342
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/pipes_solved.png" alt="Pipes" width="140">
|
|
343
|
+
</a>
|
|
344
|
+
</td>
|
|
345
|
+
</tr>
|
|
346
|
+
<tr>
|
|
347
|
+
<td align="center">
|
|
348
|
+
<a href="https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/connect_the_dots"><b>Connect the Dots</b><br><br>
|
|
349
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/connect_the_dots_solved.png" alt="Connect the Dots" width="140">
|
|
350
|
+
</a>
|
|
351
|
+
</td>
|
|
352
|
+
<td align="center">
|
|
353
|
+
<a href="https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/nonograms"><b>Nonograms Colored</b><br><br>
|
|
354
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/nonograms_colored_solved.png" alt="Nonograms Colored" width="140">
|
|
355
|
+
</a>
|
|
356
|
+
</td>
|
|
357
|
+
<td align="center">
|
|
358
|
+
<a href="https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/abc_view"><b>ABC View</b><br><br>
|
|
359
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/abc_view_solved.png" alt="ABC View" width="140">
|
|
360
|
+
</a>
|
|
361
|
+
</td>
|
|
362
|
+
<td align="center">
|
|
363
|
+
<a href="https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/mathema_grids"><b>Mathema Grids</b><br><br>
|
|
364
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/mathema_grids_solved.png" alt="Mathema Grids" width="140">
|
|
365
|
+
</a>
|
|
366
|
+
</td>
|
|
367
|
+
<td align="center">
|
|
368
|
+
<a href="https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/split_ends"><b>Split Ends</b><br><br>
|
|
369
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/split_ends_solved.png" alt="Split Ends" width="140">
|
|
370
|
+
</a>
|
|
371
|
+
</td>
|
|
372
|
+
</tr>
|
|
373
|
+
<tr>
|
|
374
|
+
<td align="center">
|
|
375
|
+
<a href="https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/n_queens"><b>N-Queens</b><br><br>
|
|
376
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/7_queens_solved.png" alt="N-Queens" width="140">
|
|
377
|
+
</a>
|
|
378
|
+
</td>
|
|
379
|
+
<td align="center">
|
|
380
|
+
<a href="https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/troix"><b>Troix</b><br><br>
|
|
381
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/troix_solved.png" alt="Troix" width="140">
|
|
382
|
+
</a>
|
|
383
|
+
</td>
|
|
384
|
+
<td align="center">
|
|
385
|
+
<a href="https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/troix"><b>Dumplings</b><br><br>
|
|
386
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/dumplings_solved.png" alt="Dumplings" width="140">
|
|
387
|
+
</a>
|
|
388
|
+
</td>
|
|
389
|
+
<td align="center">
|
|
390
|
+
<a href="https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/hidoku"><b>Hidoku</b><br><br>
|
|
391
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/hidoku_solved.png" alt="Hidoku" width="140">
|
|
392
|
+
</a>
|
|
393
|
+
</td>
|
|
394
|
+
<td align="center">
|
|
395
|
+
<a href="https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/suko"><b>Suko</b><br><br>
|
|
396
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/suko_solved.png" alt="Suko" width="140">
|
|
397
|
+
</a>
|
|
398
|
+
</td>
|
|
399
|
+
</tr>
|
|
400
|
+
<tr>
|
|
401
|
+
<td align="center">
|
|
402
|
+
<a href="https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/suguru"><b>Suguru</b><br><br>
|
|
403
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/suguru_solved.png" alt="Suguru" width="140">
|
|
404
|
+
</a>
|
|
405
|
+
</td>
|
|
406
|
+
<td align="center">
|
|
407
|
+
<a href="https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/number_path"><b>Number Path</b><br><br>
|
|
408
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/number_path_solved.png" alt="Number Path" width="140">
|
|
409
|
+
</a>
|
|
410
|
+
</td>
|
|
411
|
+
<td align="center">
|
|
412
|
+
<a href="https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/yajilin"><b>Yajilin</b><br><br>
|
|
413
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/yajilin_solved.png" alt="Yajilin" width="140">
|
|
414
|
+
</a>
|
|
415
|
+
</td>
|
|
416
|
+
<td align="center">
|
|
417
|
+
<a href="https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/numbermaze"><b>Number Maze</b><br><br>
|
|
418
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/numbermaze_solved.png" alt="Number Maze" width="140">
|
|
419
|
+
</a>
|
|
420
|
+
</td>
|
|
421
|
+
<td align="center">
|
|
422
|
+
<a href="https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/link_a_pix"><b>Link-a-Pix</b><br><br>
|
|
423
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/link_a_pix_solved.png" alt="Link-a-Pix" width="140">
|
|
424
|
+
</a>
|
|
425
|
+
</td>
|
|
426
|
+
</tr>
|
|
427
|
+
<tr>
|
|
428
|
+
<td align="center">
|
|
429
|
+
<a href="https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/trees_logic"><b>Trees Logic</b><br><br>
|
|
430
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/trees_logic_solved.png" alt="Trees Logic" width="140">
|
|
431
|
+
</a>
|
|
432
|
+
</td>
|
|
433
|
+
<td align="center">
|
|
434
|
+
<a href="https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/vectors"><b>Vectors</b><br><br>
|
|
435
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/vectors_solved.png" alt="Vectors" width="140">
|
|
436
|
+
</a>
|
|
437
|
+
</td>
|
|
438
|
+
<td align="center">
|
|
439
|
+
<a href="https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/vermicelli"><b>Vermicelli</b><br><br>
|
|
440
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/vermicelli_solved.png" alt="Vermicelli" width="140">
|
|
441
|
+
</a>
|
|
442
|
+
</td>
|
|
443
|
+
<td align="center">
|
|
444
|
+
<a href="https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/cow_and_cactus"><b>Cow and Cactus</b><br><br>
|
|
445
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/cow_and_cactus_solved.png" alt="Cow and Cactus" width="140">
|
|
446
|
+
</a>
|
|
447
|
+
</td>
|
|
448
|
+
<td align="center">
|
|
449
|
+
<a href="https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/kropki"><b>Kropki</b><br><br>
|
|
450
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/kropki_solved.png" alt="Kropki" width="140">
|
|
451
|
+
</a>
|
|
452
|
+
</td>
|
|
453
|
+
</tr>
|
|
454
|
+
<tr>
|
|
455
|
+
<td align="center">
|
|
456
|
+
<a href="https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/ripple_effect"><b>Ripple Effect</b><br><br>
|
|
457
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/ripple_effect_solved.png" alt="Ripple Effect" width="140">
|
|
458
|
+
</a>
|
|
459
|
+
</td>
|
|
460
|
+
<td align="center">
|
|
461
|
+
<a href="https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/area_51"><b>Area 51</b><br><br>
|
|
462
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/area_51_solved.png" alt="Area 51" width="140">
|
|
463
|
+
</a>
|
|
464
|
+
</td>
|
|
465
|
+
<td align="center">
|
|
466
|
+
<a href="https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/circle_9"><b>Circle 9</b><br><br>
|
|
467
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/circle_9_solved.png" alt="Circle 9" width="140">
|
|
468
|
+
</a>
|
|
469
|
+
</td>
|
|
470
|
+
<td align="center">
|
|
471
|
+
<a href="https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/kakuro"><b>Krypto Kakuro</b><br><br>
|
|
472
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/krypto_kakuro_solved.png" alt="Krypto Kakuro" width="140">
|
|
473
|
+
</a>
|
|
474
|
+
</td>
|
|
475
|
+
<td align="center">
|
|
476
|
+
<a href="https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/snail"><b>Snail</b><br><br>
|
|
477
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/snail_solved.png" alt="Snail" width="140">
|
|
478
|
+
</a>
|
|
479
|
+
</td>
|
|
480
|
+
</tr>
|
|
481
|
+
<tr>
|
|
482
|
+
<td align="center">
|
|
483
|
+
<a href="https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/hidden_stars"><b>Hidden Stars</b><br><br>
|
|
484
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/hidden_stars_solved.png" alt="Hidden Stars" width="140">
|
|
485
|
+
</a>
|
|
486
|
+
</td>
|
|
487
|
+
<td align="center">
|
|
488
|
+
<a href="https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/branches"><b>Branches</b><br><br>
|
|
489
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/branches_solved.png" alt="Branches" width="140">
|
|
490
|
+
</a>
|
|
491
|
+
</td>
|
|
492
|
+
<td align="center">
|
|
493
|
+
<a href="https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/tatami"><b>Tatami</b><br><br>
|
|
494
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/tatami_solved.png" alt="Tatami" width="140">
|
|
495
|
+
</a>
|
|
496
|
+
</td>
|
|
497
|
+
<td align="center">
|
|
498
|
+
<a href="https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/linesweeper"><b>Linesweeper</b><br><br>
|
|
499
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/linesweeper_solved.png" alt="Linesweeper" width="140">
|
|
500
|
+
</a>
|
|
501
|
+
</td>
|
|
502
|
+
<td align="center">
|
|
503
|
+
<a href="https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/clouds"><b>Clouds</b><br><br>
|
|
504
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/clouds_solved.png" alt="Clouds" width="140">
|
|
505
|
+
</a>
|
|
506
|
+
</td>
|
|
507
|
+
</tr>
|
|
508
|
+
<tr>
|
|
509
|
+
<td align="center">
|
|
510
|
+
<a href="https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/walls"><b>Walls</b><br><br>
|
|
511
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/walls_solved.png" alt="Walls" width="140">
|
|
512
|
+
</a>
|
|
513
|
+
</td>
|
|
514
|
+
<td align="center">
|
|
515
|
+
<a href="https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/rooms"><b>Rooms</b><br><br>
|
|
516
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/rooms_solved.png" alt="Rooms" width="140">
|
|
517
|
+
</a>
|
|
518
|
+
</td>
|
|
519
|
+
<td align="center">
|
|
520
|
+
<a href="https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/mathrax"><b>Mathrax</b><br><br>
|
|
521
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/mathrax_solved.png" alt="Mathrax" width="140">
|
|
522
|
+
</a>
|
|
523
|
+
</td>
|
|
524
|
+
</tr>
|
|
525
|
+
|
|
526
|
+
<!-- AUTO-GENERATED GALLERY END -->
|
|
527
|
+
</table>
|
|
528
|
+
|
|
529
|
+
</div>
|
|
530
|
+
|
|
531
|
+
---
|
|
532
|
+
|
|
533
|
+
## Introduction
|
|
534
|
+
|
|
535
|
+
The aim of this repo is to provide very efficient solvers (i.e. not brute force solvers) for countless (85+) popular pencil logic puzzles like Nonograms, Sudoku, Minesweeper, and many more lesser known ones.
|
|
536
|
+
|
|
537
|
+
If you happen to have a puzzle similar to the ones listed below and want to solve it (or see how many potential solutions a partially covered board has), then this repo is perfect for you.
|
|
538
|
+
|
|
539
|
+
The simple use-case of this repo is if you want to solve a puzzle given the state of the board. But the other interesting use-cases is if you want to check if removing a clue would still result in a unique solution or would make the puzzle ambiguous and have multiple solutions.
|
|
540
|
+
|
|
541
|
+
**Why?** There are countless python packages that can solve the popular puzzles below, so a valid question to ask is **why would I want to use this package and why did you create it?**. The answer is that there are multiple problems with most of those packages which this package solves which are:
|
|
542
|
+
|
|
543
|
+
1. **Sophisticated solvers:** A lot of available online solvers are incredibly inefficient as they implement naive algorithms that brute force and backtrack through all possible solutions. This package solves that issue as all the solvers included here never use naive algorithms and instead use a very efficient CP-SAT solver which is a more sophisticated solver than any one person could possibly write.
|
|
544
|
+
2. **Numerous puzzles:** Most of the available python solvers are only designed for a single type of puzzle and each one requires a different way to encode the input and extract the solution. This package solves both those issues as this package provides solvers for many puzzles all with a similar interface that encodes the input and extracts the solution in a similar way.
|
|
545
|
+
3. **Esoteric puzzles:** Most packages you can find online are only designed for popular puzzles. This package partially solves this issue by providing solvers for many puzzles. I'm open to suggestions for implementing solvers for more puzzles.
|
|
546
|
+
4. **All possible solutions:** The available solvers often lack uniqueness checks and simply stop at the first possible solution without verifying uniqueness or completeness. This package supports checking whether puzzles are uniquely solvable, ambiguous, or unsolvable for all the puzzles.
|
|
547
|
+
|
|
548
|
+
Play most of the puzzles online in the website listed in the [Puzzle List](https://github.com/Ar-Kareem/puzzle_solver/blob/master/images/puzzle_list/README.md).
|
|
549
|
+
|
|
550
|
+
|
|
551
|
+
Almost all the solvers in this repo use the CP-SAT solver from Google OR-Tools.
|
|
552
|
+
|
|
553
|
+
|
|
554
|
+
## Quick Start
|
|
555
|
+
|
|
556
|
+
Install
|
|
557
|
+
|
|
558
|
+
```bash
|
|
559
|
+
pip install multi-puzzle-solver
|
|
560
|
+
```
|
|
561
|
+
|
|
562
|
+
Use:
|
|
563
|
+
|
|
564
|
+
```python
|
|
565
|
+
from puzzle_solver import nonograms_solver as solver
|
|
566
|
+
top_numbers = [[8, 2], [5, 4], [2, 1, 4], [2, 4], [2, 1, 4], [2, 5], [2, 8], [3, 2], [1, 6], [1, 9], [1, 6, 1], [1, 5, 3], [3, 2, 1], [4, 2], [1, 5]]
|
|
567
|
+
side_numbers = [[7, 3], [7, 1, 1], [2, 3], [2, 3], [3, 2], [1, 1, 1, 1, 2], [1, 6, 1], [1, 9], [9], [2, 4], [8], [11], [7, 1, 1], [4, 3], [3, 2]]
|
|
568
|
+
binst = solver.Board(top=top_numbers, side=side_numbers)
|
|
569
|
+
solutions = binst.solve_and_print()
|
|
570
|
+
```
|
|
571
|
+
|
|
572
|
+
Output:
|
|
573
|
+
|
|
574
|
+
```python
|
|
575
|
+
Solution found
|
|
576
|
+
[['B' 'B' 'B' 'B' 'B' 'B' 'B' ' ' 'B' 'B' 'B' ' ' ' ' ' ' ' ']
|
|
577
|
+
['B' 'B' 'B' 'B' 'B' 'B' 'B' ' ' ' ' ' ' ' ' ' ' 'B' ' ' 'B']
|
|
578
|
+
['B' 'B' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' 'B' 'B' 'B' ' ']
|
|
579
|
+
['B' 'B' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' 'B' 'B' 'B']
|
|
580
|
+
['B' 'B' 'B' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' 'B' 'B']
|
|
581
|
+
['B' ' ' ' ' ' ' 'B' ' ' 'B' ' ' ' ' 'B' ' ' ' ' ' ' 'B' 'B']
|
|
582
|
+
['B' ' ' ' ' ' ' ' ' ' ' 'B' 'B' 'B' 'B' 'B' 'B' ' ' ' ' 'B']
|
|
583
|
+
['B' ' ' ' ' ' ' ' ' ' ' 'B' 'B' 'B' 'B' 'B' 'B' 'B' 'B' 'B']
|
|
584
|
+
[' ' ' ' ' ' ' ' ' ' 'B' 'B' 'B' 'B' 'B' 'B' 'B' 'B' 'B' ' ']
|
|
585
|
+
[' ' ' ' ' ' ' ' ' ' 'B' 'B' ' ' 'B' 'B' 'B' 'B' ' ' ' ' ' ']
|
|
586
|
+
[' ' ' ' ' ' ' ' 'B' 'B' 'B' 'B' 'B' 'B' 'B' 'B' ' ' ' ' ' ']
|
|
587
|
+
['B' 'B' 'B' 'B' 'B' 'B' 'B' 'B' 'B' 'B' 'B' ' ' ' ' ' ' ' ']
|
|
588
|
+
['B' 'B' 'B' 'B' 'B' 'B' 'B' ' ' ' ' 'B' ' ' 'B' ' ' ' ' ' ']
|
|
589
|
+
[' ' 'B' 'B' 'B' 'B' ' ' ' ' ' ' ' ' 'B' 'B' 'B' ' ' ' ' ' ']
|
|
590
|
+
[' ' 'B' 'B' 'B' ' ' ' ' ' ' ' ' ' ' ' ' ' ' 'B' 'B' ' ' ' ']]
|
|
591
|
+
Solutions found: 1
|
|
592
|
+
status: OPTIMAL
|
|
593
|
+
Time taken: 0.04 seconds
|
|
594
|
+
```
|
|
595
|
+
(Note: Printing can be turned off by setting `verbose=False`)
|
|
596
|
+
|
|
597
|
+
## Table of Contents
|
|
598
|
+
|
|
599
|
+
- [Python Puzzle Solver](#python-puzzle-solver)
|
|
600
|
+
- [Install](#install)
|
|
601
|
+
- [🕹️ Puzzle Gallery](#️-puzzle-gallery)
|
|
602
|
+
- [Introduction](#introduction)
|
|
603
|
+
- [Quick Start](#quick-start)
|
|
604
|
+
- [Table of Contents](#table-of-contents)
|
|
605
|
+
- [Puzzles](#puzzles)
|
|
606
|
+
- [Sudoku (Puzzle Type #2)](#sudoku-puzzle-type-2)
|
|
607
|
+
- [Filling (Puzzle Type #7)](#filling-puzzle-type-7)
|
|
608
|
+
- [Singles (Puzzle Type #10)](#singles-puzzle-type-10)
|
|
609
|
+
- [Range (Puzzle Type #13)](#range-puzzle-type-13)
|
|
610
|
+
- [Tracks (Puzzle Type #16)](#tracks-puzzle-type-16)
|
|
611
|
+
- [Pearl (Puzzle Type #19)](#pearl-puzzle-type-19)
|
|
612
|
+
- [Inertia (Puzzle Type #21)](#inertia-puzzle-type-21)
|
|
613
|
+
- [Guess (Puzzle Type #22)](#guess-puzzle-type-22)
|
|
614
|
+
- [Chess Melee (Puzzle Type #25)](#chess-melee-puzzle-type-25)
|
|
615
|
+
- [Aquarium (Puzzle Type #27)](#aquarium-puzzle-type-27)
|
|
616
|
+
- [Stitches (Puzzle Type #28)](#stitches-puzzle-type-28)
|
|
617
|
+
- [Battleships (Puzzle Type #29)](#battleships-puzzle-type-29)
|
|
618
|
+
- [Star Battle Shapeless (Puzzle Type #32)](#star-battle-shapeless-puzzle-type-32)
|
|
619
|
+
- [Lits (Puzzle Type #33)](#lits-puzzle-type-33)
|
|
620
|
+
- [Galaxies (Puzzle Type #35)](#galaxies-puzzle-type-35)
|
|
621
|
+
- [Slitherlink (Puzzle Type #39)](#slitherlink-puzzle-type-39)
|
|
622
|
+
- [Rectangles (Puzzle Type #42)](#rectangles-puzzle-type-42)
|
|
623
|
+
- [Palisade (Puzzle Type #43)](#palisade-puzzle-type-43)
|
|
624
|
+
- [Heyawake (Puzzle Type #46)](#heyawake-puzzle-type-46)
|
|
625
|
+
- [Shingoki (Puzzle Type #47)](#shingoki-puzzle-type-47)
|
|
626
|
+
- [Shakashaka (Puzzle Type #50)](#shakashaka-puzzle-type-50)
|
|
627
|
+
- [Sudoku Killer (Puzzle Type #53)](#sudoku-killer-puzzle-type-53)
|
|
628
|
+
- [Flood It (Puzzle Type #54)](#flood-it-puzzle-type-54)
|
|
629
|
+
- [Pipes (Puzzle Type #55)](#pipes-puzzle-type-55)
|
|
630
|
+
- [Connect the Dots (Puzzle Type #56)](#connect-the-dots-puzzle-type-56)
|
|
631
|
+
- [Nonograms Colored (Puzzle Type #57)](#nonograms-colored-puzzle-type-57)
|
|
632
|
+
- [Split Ends (Puzzle Type #60)](#split-ends-puzzle-type-60)
|
|
633
|
+
- [N-Queens (Puzzle Type #61)](#n-queens-puzzle-type-61)
|
|
634
|
+
- [Suguru (Puzzle Type #66)](#suguru-puzzle-type-66)
|
|
635
|
+
- [Yajilin (Puzzle Type #68)](#yajilin-puzzle-type-68)
|
|
636
|
+
- [NumberMaze (Puzzle Type #69)](#numbermaze-puzzle-type-69)
|
|
637
|
+
- [Link-a-Pix (Puzzle Type #70)](#link-a-pix-puzzle-type-70)
|
|
638
|
+
- [Vectors (Puzzle Type #72)](#vectors-puzzle-type-72)
|
|
639
|
+
- [Vermicelli (Puzzle Type #73)](#vermicelli-puzzle-type-73)
|
|
640
|
+
- [Cow and Cactus (Puzzle Type #74)](#cow-and-cactus-puzzle-type-74)
|
|
641
|
+
- [Ripple Effect (Puzzle Type #76)](#ripple-effect-puzzle-type-76)
|
|
642
|
+
- [Area 51 (Puzzle Type #77)](#area-51-puzzle-type-77)
|
|
643
|
+
- [All other Puzzles](#all-other-puzzles)
|
|
644
|
+
- [Aliases](#aliases)
|
|
645
|
+
- [Other](#other)
|
|
646
|
+
- [Why SAT / CP-SAT?](#why-sat--cp-sat)
|
|
647
|
+
- [Testing](#testing)
|
|
648
|
+
- [Contributing](#contributing)
|
|
649
|
+
- [Build and push to PyPI](#build-and-push-to-pypi)
|
|
650
|
+
|
|
651
|
+
---
|
|
652
|
+
|
|
653
|
+
# Puzzles
|
|
654
|
+
|
|
655
|
+
Each puzzle in this repo have a simple example input board followed by the code to utilize this package and solve the puzzle, followed by the scripts output, and finally the solved puzzle.
|
|
656
|
+
|
|
657
|
+
Some of the puzzles implemented are shown below.
|
|
658
|
+
|
|
659
|
+
## Sudoku (Puzzle Type #2)
|
|
660
|
+
|
|
661
|
+
Also known as Number Place or Solo.
|
|
662
|
+
|
|
663
|
+
The code can:
|
|
664
|
+
|
|
665
|
+
1. Solve arbitrarily sized valid board sizes, thus can be used to solve:
|
|
666
|
+
- Hex Sudoku (a 16x16 variant)
|
|
667
|
+
- Kidoku (a kid-friendly sudoku variant)
|
|
668
|
+
2. Solve the ["Sandwich" sudoku variant](https://dkmgames.com/SandwichSudoku/) using the optional parameter `sandwich={'side': [...], 'bottom': [...]}`
|
|
669
|
+
3. Solve the ["Sudoku-X" variant](https://www.sudopedia.org/wiki/Sudoku-X) using the optional parameter `unique_diagonal=True`
|
|
670
|
+
|
|
671
|
+
* [**Play online**](https://www.chiark.greenend.org.uk/~sgtatham/puzzles/js/solo.html)
|
|
672
|
+
|
|
673
|
+
* [**Instructions**](https://www.chiark.greenend.org.uk/~sgtatham/puzzles/doc/solo.html#solo)
|
|
674
|
+
|
|
675
|
+
* [**Solver Code**](https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/sudoku)
|
|
676
|
+
|
|
677
|
+
<details>
|
|
678
|
+
<summary><strong>Rules</strong></summary>
|
|
679
|
+
|
|
680
|
+
You have a square grid, which is divided into as many equally sized sub-blocks as the grid has rows. Each square must be filled in with a digit from 1 to the size of the grid, in such a way that
|
|
681
|
+
|
|
682
|
+
- every row contains only one occurrence of each digit
|
|
683
|
+
- every column contains only one occurrence of each digit
|
|
684
|
+
- every block contains only one occurrence of each digit.
|
|
685
|
+
|
|
686
|
+
You are given some of the numbers as clues; your aim is to place the rest of the numbers correctly.
|
|
687
|
+
|
|
688
|
+
</details>
|
|
689
|
+
|
|
690
|
+
**Unsolved puzzle**
|
|
691
|
+
|
|
692
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/sudoku_unsolved.png" alt="Sudoku unsolved" width="500">
|
|
693
|
+
|
|
694
|
+
Code to utilize this package and solve the puzzle:
|
|
695
|
+
|
|
696
|
+
```python
|
|
697
|
+
import numpy as np
|
|
698
|
+
from puzzle_solver import sudoku_solver as solver
|
|
699
|
+
board = np.array([
|
|
700
|
+
[' ', '7', '5', '4', '9', '1', 'c', 'e', 'd', 'f', ' ', ' ', '2', ' ', '3', ' '],
|
|
701
|
+
[' ', ' ', ' ', ' ', 'f', 'a', ' ', ' ', ' ', '6', ' ', 'c', ' ', ' ', '8', 'b'],
|
|
702
|
+
[' ', ' ', '1', ' ', ' ', '6', ' ', ' ', ' ', '9', ' ', ' ', ' ', 'g', ' ', 'd'],
|
|
703
|
+
[' ', '6', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '5', 'g', 'c', '7', ' ', ' '],
|
|
704
|
+
|
|
705
|
+
['4', 'a', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '9', ' ', ' ', ' ', ' '],
|
|
706
|
+
[' ', 'g', 'f', ' ', 'e', ' ', ' ', '5', '4', ' ', ' ', '1', ' ', '9', ' ', '8'],
|
|
707
|
+
[' ', ' ', ' ', ' ', 'a', '3', 'b', '7', 'c', 'g', ' ', '6', ' ', ' ', ' ', '4'],
|
|
708
|
+
[' ', 'b', ' ', '7', ' ', ' ', ' ', ' ', 'f', ' ', '3', ' ', ' ', 'a', ' ', '6'],
|
|
709
|
+
|
|
710
|
+
['2', ' ', 'a', ' ', ' ', 'c', ' ', '1', ' ', ' ', ' ', ' ', '7', ' ', '6', ' '],
|
|
711
|
+
['8', ' ', ' ', ' ', '3', ' ', 'e', 'f', '7', '5', 'c', 'd', ' ', ' ', ' ', ' '],
|
|
712
|
+
['9', ' ', '3', ' ', '7', ' ', ' ', 'a', '6', ' ', ' ', '2', ' ', 'b', '1', ' '],
|
|
713
|
+
[' ', ' ', ' ', ' ', '4', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'e', 'f'],
|
|
714
|
+
|
|
715
|
+
[' ', ' ', 'g', 'd', '2', '9', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '4', ' '],
|
|
716
|
+
['a', ' ', 'b', ' ', ' ', ' ', '5', ' ', ' ', ' ', 'd', ' ', ' ', '8', ' ', ' '],
|
|
717
|
+
['e', '8', ' ', ' ', '1', ' ', '4', ' ', ' ', ' ', '6', '7', ' ', ' ', ' ', ' '],
|
|
718
|
+
[' ', '3', ' ', '9', ' ', ' ', 'f', '8', 'a', 'e', 'g', '5', 'b', 'c', 'd', ' '],
|
|
719
|
+
])
|
|
720
|
+
binst = solver.Board(board=board)
|
|
721
|
+
solutions = binst.solve_and_print()
|
|
722
|
+
assert len(solutions) == 1, f'unique solutions != 1, == {len(solutions)}'
|
|
723
|
+
```
|
|
724
|
+
**Script Output**
|
|
725
|
+
```python
|
|
726
|
+
Solution found
|
|
727
|
+
0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1
|
|
728
|
+
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
|
|
729
|
+
┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┐
|
|
730
|
+
0│ g │ 7 │ 5 │ 4 │ 9 │ 1 │ c │ e │ d │ f │ b │ 8 │ 2 │ 6 │ 3 │ a │
|
|
731
|
+
├───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┤
|
|
732
|
+
1│ 3 │ 9 │ d │ e │ f │ a │ 7 │ g │ 2 │ 6 │ 4 │ c │ 5 │ 1 │ 8 │ b │
|
|
733
|
+
├───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┤
|
|
734
|
+
2│ b │ c │ 1 │ 8 │ 5 │ 6 │ 3 │ 2 │ e │ 9 │ 7 │ a │ 4 │ g │ f │ d │
|
|
735
|
+
├───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┤
|
|
736
|
+
3│ f │ 6 │ 2 │ a │ b │ 8 │ d │ 4 │ 1 │ 3 │ 5 │ g │ c │ 7 │ 9 │ e │
|
|
737
|
+
├───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┤
|
|
738
|
+
4│ 4 │ a │ e │ 3 │ 8 │ f │ 1 │ 6 │ 5 │ b │ 2 │ 9 │ g │ d │ c │ 7 │
|
|
739
|
+
├───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┤
|
|
740
|
+
5│ 6 │ g │ f │ c │ e │ d │ 2 │ 5 │ 4 │ 7 │ a │ 1 │ 3 │ 9 │ b │ 8 │
|
|
741
|
+
├───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┤
|
|
742
|
+
6│ d │ 1 │ 9 │ 2 │ a │ 3 │ b │ 7 │ c │ g │ 8 │ 6 │ e │ f │ 5 │ 4 │
|
|
743
|
+
├───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┤
|
|
744
|
+
7│ 5 │ b │ 8 │ 7 │ g │ 4 │ 9 │ c │ f │ d │ 3 │ e │ 1 │ a │ 2 │ 6 │
|
|
745
|
+
├───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┤
|
|
746
|
+
8│ 2 │ e │ a │ b │ d │ c │ g │ 1 │ 3 │ 8 │ 9 │ f │ 7 │ 4 │ 6 │ 5 │
|
|
747
|
+
├───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┤
|
|
748
|
+
9│ 8 │ 4 │ 6 │ 1 │ 3 │ b │ e │ f │ 7 │ 5 │ c │ d │ a │ 2 │ g │ 9 │
|
|
749
|
+
├───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┤
|
|
750
|
+
10│ 9 │ f │ 3 │ g │ 7 │ 5 │ 8 │ a │ 6 │ 4 │ e │ 2 │ d │ b │ 1 │ c │
|
|
751
|
+
├───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┤
|
|
752
|
+
11│ c │ d │ 7 │ 5 │ 4 │ 2 │ 6 │ 9 │ g │ a │ 1 │ b │ 8 │ 3 │ e │ f │
|
|
753
|
+
├───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┤
|
|
754
|
+
12│ 7 │ 5 │ g │ d │ 2 │ 9 │ a │ b │ 8 │ c │ f │ 3 │ 6 │ e │ 4 │ 1 │
|
|
755
|
+
├───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┤
|
|
756
|
+
13│ a │ 2 │ b │ 6 │ c │ e │ 5 │ 3 │ 9 │ 1 │ d │ 4 │ f │ 8 │ 7 │ g │
|
|
757
|
+
├───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┤
|
|
758
|
+
14│ e │ 8 │ c │ f │ 1 │ g │ 4 │ d │ b │ 2 │ 6 │ 7 │ 9 │ 5 │ a │ 3 │
|
|
759
|
+
├───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┤
|
|
760
|
+
15│ 1 │ 3 │ 4 │ 9 │ 6 │ 7 │ f │ 8 │ a │ e │ g │ 5 │ b │ c │ d │ 2 │
|
|
761
|
+
└───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┘
|
|
762
|
+
Solutions found: 1
|
|
763
|
+
status: OPTIMAL
|
|
764
|
+
Time taken: 0.04 seconds
|
|
765
|
+
```
|
|
766
|
+
|
|
767
|
+
**Solved puzzle**
|
|
768
|
+
|
|
769
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/sudoku_solved.png" alt="Sudoku solved" width="500">
|
|
770
|
+
|
|
771
|
+
---
|
|
772
|
+
|
|
773
|
+
## Filling (Puzzle Type #7)
|
|
774
|
+
|
|
775
|
+
Also known as Fillomino
|
|
776
|
+
|
|
777
|
+
* [**Play online**](https://www.chiark.greenend.org.uk/~sgtatham/puzzles/js/filling.html)
|
|
778
|
+
|
|
779
|
+
* [**Instructions**](https://www.chiark.greenend.org.uk/~sgtatham/puzzles/doc/filling.html#filling)
|
|
780
|
+
|
|
781
|
+
* [**Solver Code**](https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/filling)
|
|
782
|
+
|
|
783
|
+
<details>
|
|
784
|
+
<summary><strong>Rules</strong></summary>
|
|
785
|
+
|
|
786
|
+
You have a grid of squares, some of which contain digits, and the rest of which are empty. Your job is to fill in digits in the empty squares, in such a way that each connected region of squares all containing the same digit has an area equal to that digit.
|
|
787
|
+
|
|
788
|
+
(‘Connected region’, for the purposes of this game, does not count diagonally separated squares as adjacent.)
|
|
789
|
+
|
|
790
|
+
For example, it follows that no square can contain a zero, and that two adjacent squares can not both contain a one. No region has an area greater than 9 (because then its area would not be a single digit).
|
|
791
|
+
|
|
792
|
+
</details>
|
|
793
|
+
|
|
794
|
+
Note: It may take a few seconds for the model to be built.
|
|
795
|
+
|
|
796
|
+
**Unsolved puzzle**
|
|
797
|
+
|
|
798
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/filling_unsolved.png" alt="Filling unsolved" width="500">
|
|
799
|
+
|
|
800
|
+
Code to utilize this package and solve the puzzle:
|
|
801
|
+
```python
|
|
802
|
+
import numpy as np
|
|
803
|
+
from puzzle_solver import filling_solver as solver
|
|
804
|
+
board = np.array([
|
|
805
|
+
[' ', '4', '2', ' ', ' ', '2', ' '],
|
|
806
|
+
[' ', ' ', '7', ' ', ' ', '3', ' '],
|
|
807
|
+
[' ', ' ', ' ', ' ', '4', ' ', '3'],
|
|
808
|
+
[' ', '6', '6', ' ', '3', ' ', ' '],
|
|
809
|
+
[' ', '7', ' ', '6', '4', '5', ' '],
|
|
810
|
+
[' ', '6', ' ', ' ', ' ', ' ', '4'],
|
|
811
|
+
])
|
|
812
|
+
binst = solver.Board(board=board)
|
|
813
|
+
solutions = binst.solve_and_print()
|
|
814
|
+
```
|
|
815
|
+
**Script Output**
|
|
816
|
+
```python
|
|
817
|
+
Solution found
|
|
818
|
+
|
|
819
|
+
0 1 2 3 4 5 6
|
|
820
|
+
┌───────┬───────┬───┬───────┐
|
|
821
|
+
0│ 4 4 │ 2 2 │ 4 │ 2 2 │
|
|
822
|
+
│ ├───┬───┘ ├───────┤
|
|
823
|
+
1│ 4 4 │ 7 │ 4 4 │ 3 3 │
|
|
824
|
+
├───────┘ ├───┐ ├───┐ │
|
|
825
|
+
2│ 7 7 7 │ 3 │ 4 │ 5 │ 3 │
|
|
826
|
+
│ ┌───────┤ └───┤ └───┤
|
|
827
|
+
3│ 7 │ 6 6 │ 3 3 │ 5 5 │
|
|
828
|
+
│ └───┐ └───┬───┤ │
|
|
829
|
+
4│ 7 7 │ 6 6 │ 4 │ 5 5 │
|
|
830
|
+
├───┬───┘ ┌───┤ └───────┤
|
|
831
|
+
5│ 1 │ 6 6 │ 1 │ 4 4 4 │
|
|
832
|
+
└───┴───────┴───┴───────────┘
|
|
833
|
+
Solutions found: 1
|
|
834
|
+
status: OPTIMAL
|
|
835
|
+
Time taken: 0.15 seconds
|
|
836
|
+
```
|
|
837
|
+
|
|
838
|
+
**Solved puzzle**
|
|
839
|
+
|
|
840
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/filling_solved.png" alt="Filling solved" width="500">
|
|
841
|
+
|
|
842
|
+
---
|
|
843
|
+
|
|
844
|
+
## Singles (Puzzle Type #10)
|
|
845
|
+
|
|
846
|
+
Also known as Hitori.
|
|
847
|
+
|
|
848
|
+
* [**Play online 1**](https://www.chiark.greenend.org.uk/~sgtatham/puzzles/js/singles.html)
|
|
849
|
+
|
|
850
|
+
* [**Play online 2**](https://www.puzzle-hitori.com/)
|
|
851
|
+
|
|
852
|
+
* [**Instructions**](https://www.chiark.greenend.org.uk/~sgtatham/puzzles/doc/singles.html#singles)
|
|
853
|
+
|
|
854
|
+
* [**Solver Code**](https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/singles)
|
|
855
|
+
<summary><strong>Rules</strong></summary>
|
|
856
|
+
|
|
857
|
+
You have a grid of white squares, all of which contain numbers. Your task is to colour some of the squares black (removing the number) so as to satisfy all of the following conditions:
|
|
858
|
+
|
|
859
|
+
- No number occurs more than once in any row or column.
|
|
860
|
+
- No black square is horizontally or vertically adjacent to any other black square.
|
|
861
|
+
- The remaining white squares must all form one contiguous region (connected by edges, not just touching at corners).
|
|
862
|
+
|
|
863
|
+
</details>
|
|
864
|
+
|
|
865
|
+
**Unsolved puzzle**
|
|
866
|
+
|
|
867
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/singles_unsolved.png" alt="Singles unsolved" width="500">
|
|
868
|
+
|
|
869
|
+
Code to utilize this package and solve the puzzle:
|
|
870
|
+
```python
|
|
871
|
+
import numpy as np
|
|
872
|
+
from puzzle_solver import singles_solver as solver
|
|
873
|
+
board = np.array([
|
|
874
|
+
[1, 6, 5, 4, 9, 8, 9, 3, 5, 1, 3, 7],
|
|
875
|
+
[2, 8, 5, 7, 1, 1, 4, 3, 6, 3, 10, 7],
|
|
876
|
+
[6, 7, 7, 11, 2, 6, 3, 10, 10, 2, 3, 3],
|
|
877
|
+
[11, 9, 4, 3, 6, 1, 2, 5, 3, 10, 7, 8],
|
|
878
|
+
[5, 5, 4, 9, 7, 9, 6, 6, 11, 5, 4, 11],
|
|
879
|
+
[1, 3, 7, 9, 12, 5, 4, 2, 9, 6, 12, 4],
|
|
880
|
+
[6, 11, 1, 3, 6, 4, 11, 2, 2, 10, 8, 10],
|
|
881
|
+
[3, 11, 12, 6, 2, 9, 9, 1, 4, 8, 12, 5],
|
|
882
|
+
[4, 8, 8, 5, 11, 3, 3, 6, 5, 9, 1, 4],
|
|
883
|
+
[2, 4, 6, 2, 1, 10, 1, 10, 8, 5, 4, 6],
|
|
884
|
+
[5, 1, 6, 10, 9, 4, 8, 4, 8, 3, 2, 12],
|
|
885
|
+
[11, 2, 12, 10, 8, 3, 5, 4, 10, 4, 8, 11],
|
|
886
|
+
])
|
|
887
|
+
binst = solver.Board(board=board)
|
|
888
|
+
solutions = binst.solve_and_print()
|
|
889
|
+
```
|
|
890
|
+
|
|
891
|
+
**Script Output**
|
|
892
|
+
|
|
893
|
+
```python
|
|
894
|
+
Solution found
|
|
895
|
+
0 0 0 0 0 0 0 0 0 0 1 1
|
|
896
|
+
0 1 2 3 4 5 6 7 8 9 0 1
|
|
897
|
+
┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┐
|
|
898
|
+
0│▒▒▒│ 6 │▒▒▒│ 4 │▒▒▒│ 8 │ 9 │▒▒▒│ 5 │ 1 │ 3 │ 7 │
|
|
899
|
+
├───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┤
|
|
900
|
+
1│ 2 │ 8 │ 5 │ 7 │ 1 │▒▒▒│ 4 │ 3 │ 6 │▒▒▒│10 │▒▒▒│
|
|
901
|
+
├───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┤
|
|
902
|
+
2│▒▒▒│ 7 │▒▒▒│11 │▒▒▒│ 6 │▒▒▒│10 │▒▒▒│ 2 │▒▒▒│ 3 │
|
|
903
|
+
├───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┤
|
|
904
|
+
3│11 │ 9 │ 4 │▒▒▒│ 6 │ 1 │ 2 │ 5 │ 3 │10 │ 7 │ 8 │
|
|
905
|
+
├───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┤
|
|
906
|
+
4│▒▒▒│ 5 │▒▒▒│ 9 │ 7 │▒▒▒│ 6 │▒▒▒│11 │▒▒▒│ 4 │▒▒▒│
|
|
907
|
+
├───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┤
|
|
908
|
+
5│ 1 │ 3 │ 7 │▒▒▒│12 │ 5 │▒▒▒│ 2 │ 9 │ 6 │▒▒▒│ 4 │
|
|
909
|
+
├───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┤
|
|
910
|
+
6│ 6 │▒▒▒│ 1 │ 3 │▒▒▒│ 4 │11 │▒▒▒│ 2 │▒▒▒│ 8 │10 │
|
|
911
|
+
├───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┤
|
|
912
|
+
7│ 3 │11 │▒▒▒│ 6 │ 2 │ 9 │▒▒▒│ 1 │ 4 │ 8 │12 │ 5 │
|
|
913
|
+
├───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┤
|
|
914
|
+
8│ 4 │▒▒▒│ 8 │ 5 │11 │▒▒▒│ 3 │ 6 │▒▒▒│ 9 │ 1 │▒▒▒│
|
|
915
|
+
├───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┤
|
|
916
|
+
9│▒▒▒│ 4 │▒▒▒│ 2 │▒▒▒│10 │ 1 │▒▒▒│ 8 │ 5 │▒▒▒│ 6 │
|
|
917
|
+
├───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┤
|
|
918
|
+
10│ 5 │ 1 │ 6 │10 │ 9 │▒▒▒│ 8 │ 4 │▒▒▒│ 3 │ 2 │12 │
|
|
919
|
+
├───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┤
|
|
920
|
+
11│▒▒▒│ 2 │12 │▒▒▒│ 8 │ 3 │ 5 │▒▒▒│10 │ 4 │▒▒▒│11 │
|
|
921
|
+
└───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┘
|
|
922
|
+
Solutions found: 1
|
|
923
|
+
status: OPTIMAL
|
|
924
|
+
Time taken: 0.04 seconds
|
|
925
|
+
```
|
|
926
|
+
|
|
927
|
+
**Solved puzzle**
|
|
928
|
+
|
|
929
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/singles_solved.png" alt="Singles solved" width="500">
|
|
930
|
+
|
|
931
|
+
---
|
|
932
|
+
|
|
933
|
+
## Range (Puzzle Type #13)
|
|
934
|
+
|
|
935
|
+
Also known as Kurodoko.
|
|
936
|
+
|
|
937
|
+
* [**Play online 1**](https://www.chiark.greenend.org.uk/~sgtatham/puzzles/js/range.html)
|
|
938
|
+
|
|
939
|
+
* [**Play online 2**](https://www.puzzle-kurodoko.com/)
|
|
940
|
+
|
|
941
|
+
* [**Instructions**](https://www.chiark.greenend.org.uk/~sgtatham/puzzles/doc/range.html#range)
|
|
942
|
+
|
|
943
|
+
* [**Solver Code**](https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/range)
|
|
944
|
+
|
|
945
|
+
<details>
|
|
946
|
+
<summary><strong>Rules</strong></summary>
|
|
947
|
+
|
|
948
|
+
You have a grid of squares; some squares contain numbers. Your job is to colour some of the squares black, such that several criteria are satisfied:
|
|
949
|
+
|
|
950
|
+
- no square with a number is coloured black.
|
|
951
|
+
- no two black squares are adjacent (horizontally or vertically).
|
|
952
|
+
- for any two white squares, there is a path between them using only white squares.
|
|
953
|
+
- for each square with a number, that number denotes the total number of white squares reachable from that square going in a straight line in any horizontal or vertical direction until hitting a wall or a black square; the square with the number is included in the total (once).
|
|
954
|
+
|
|
955
|
+
For instance, a square containing the number one must have four black squares as its neighbors by the last criterion; but then it's impossible for it to be connected to any outside white square, which violates the second to last criterion. So no square will contain the number one.
|
|
956
|
+
|
|
957
|
+
</details>
|
|
958
|
+
|
|
959
|
+
**Unsolved puzzle**
|
|
960
|
+
|
|
961
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/range_unsolved.png" alt="Range unsolved" width="500">
|
|
962
|
+
|
|
963
|
+
Code to utilize this package and solve the puzzle:
|
|
964
|
+
```python
|
|
965
|
+
import numpy as np
|
|
966
|
+
from puzzle_solver import range_solver as solver
|
|
967
|
+
clues = np.array([
|
|
968
|
+
[' ', '4 ', '2 ', ' ', ' ', '3 ', ' ', ' ', ' ', '8 ', ' ', ' ', ' ', ' ', '6 ', ' '],
|
|
969
|
+
[' ', ' ', ' ', ' ', ' ', '13', ' ', '18', ' ', ' ', '14', ' ', ' ', '22', ' ', ' '],
|
|
970
|
+
[' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '12', ' ', ' ', ' ', ' '],
|
|
971
|
+
[' ', ' ', ' ', ' ', '12', ' ', '11', ' ', ' ', ' ', '9 ', ' ', ' ', ' ', ' ', ' '],
|
|
972
|
+
['7 ', ' ', ' ', ' ', ' ', ' ', '6 ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '],
|
|
973
|
+
[' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '],
|
|
974
|
+
[' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '12', ' ', ' ', ' ', ' ', ' ', '5 '],
|
|
975
|
+
[' ', ' ', ' ', ' ', ' ', '9 ', ' ', ' ', ' ', '9 ', ' ', '4 ', ' ', ' ', ' ', ' '],
|
|
976
|
+
[' ', ' ', ' ', ' ', '6 ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '],
|
|
977
|
+
[' ', ' ', '10', ' ', ' ', '7 ', ' ', ' ', '13', ' ', '10', ' ', ' ', ' ', ' ', ' '],
|
|
978
|
+
[' ', '7 ', ' ', ' ', ' ', ' ', '6 ', ' ', ' ', ' ', '6 ', ' ', ' ', '13', '5 ', ' '],
|
|
979
|
+
])
|
|
980
|
+
binst = solver.Board(clues)
|
|
981
|
+
solutions = binst.solve_and_print()
|
|
982
|
+
```
|
|
983
|
+
**Script Output**
|
|
984
|
+
```python
|
|
985
|
+
Solution:
|
|
986
|
+
0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1
|
|
987
|
+
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
|
|
988
|
+
┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┐
|
|
989
|
+
0│▒▒▒│ 4 │ 2 │▒▒▒│ │ 3 │▒▒▒│ │▒▒▒│ 8 │▒▒▒│ │▒▒▒│ │ 6 │ │
|
|
990
|
+
├───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┤
|
|
991
|
+
1│ │ │▒▒▒│ │ │13 │ │18 │ │ │14 │ │ │22 │ │▒▒▒│
|
|
992
|
+
├───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┤
|
|
993
|
+
2│▒▒▒│ │ │ │ │▒▒▒│ │ │ │ │ │12 │ │ │ │ │
|
|
994
|
+
├───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┤
|
|
995
|
+
3│ │▒▒▒│ │▒▒▒│12 │ │11 │ │ │ │ 9 │▒▒▒│ │ │ │ │
|
|
996
|
+
├───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┤
|
|
997
|
+
4│ 7 │ │ │ │ │▒▒▒│ 6 │ │▒▒▒│ │▒▒▒│ │ │ │▒▒▒│ │
|
|
998
|
+
├───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┤
|
|
999
|
+
5│ │ │▒▒▒│ │ │ │ │ │ │ │ │▒▒▒│ │ │ │▒▒▒│
|
|
1000
|
+
├───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┤
|
|
1001
|
+
6│▒▒▒│ │ │ │▒▒▒│ │▒▒▒│ │ │12 │ │ │▒▒▒│ │ │ 5 │
|
|
1002
|
+
├───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┤
|
|
1003
|
+
7│ │ │ │ │ │ 9 │ │▒▒▒│ │ 9 │▒▒▒│ 4 │ │ │▒▒▒│ │
|
|
1004
|
+
├───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┤
|
|
1005
|
+
8│ │▒▒▒│ │ │ 6 │▒▒▒│ │ │ │▒▒▒│ │▒▒▒│ │ │ │ │
|
|
1006
|
+
├───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┤
|
|
1007
|
+
9│ │ │10 │ │ │ 7 │▒▒▒│ │13 │ │10 │ │ │ │ │▒▒▒│
|
|
1008
|
+
├───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┤
|
|
1009
|
+
10│▒▒▒│ 7 │ │ │ │ │ 6 │▒▒▒│ │ │ 6 │ │▒▒▒│13 │ 5 │ │
|
|
1010
|
+
└───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┘
|
|
1011
|
+
Solutions found: 1
|
|
1012
|
+
status: OPTIMAL
|
|
1013
|
+
Time taken: 0.07 seconds
|
|
1014
|
+
```
|
|
1015
|
+
|
|
1016
|
+
**Solved puzzle**
|
|
1017
|
+
|
|
1018
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/range_solved.png" alt="Range solved" width="500">
|
|
1019
|
+
|
|
1020
|
+
---
|
|
1021
|
+
|
|
1022
|
+
## Tracks (Puzzle Type #16)
|
|
1023
|
+
|
|
1024
|
+
* [**Play online**](https://www.chiark.greenend.org.uk/~sgtatham/puzzles/js/tracks.html)
|
|
1025
|
+
|
|
1026
|
+
* [**Instructions**](https://www.chiark.greenend.org.uk/~sgtatham/puzzles/doc/tracks.html#tracks)
|
|
1027
|
+
|
|
1028
|
+
* [**Solver Code**](https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/tracks)
|
|
1029
|
+
|
|
1030
|
+
<details>
|
|
1031
|
+
<summary><strong>Rules</strong></summary>
|
|
1032
|
+
|
|
1033
|
+
Complete the track from A to B so that the rows and columns contain the same number of track segments as are indicated in the clues to the top and right of the grid. There are only straight and 90-degree curved rail sections, and the track may not cross itself.
|
|
1034
|
+
|
|
1035
|
+
</details>
|
|
1036
|
+
|
|
1037
|
+
**Unsolved puzzle**
|
|
1038
|
+
|
|
1039
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/tracks_unsolved.png" alt="Tracks unsolved" width="500">
|
|
1040
|
+
|
|
1041
|
+
Code to utilize this package and solve the puzzle:
|
|
1042
|
+
```python
|
|
1043
|
+
import numpy as np
|
|
1044
|
+
from puzzle_solver import tracks_solver as solver
|
|
1045
|
+
board = np.array([
|
|
1046
|
+
[' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'LD', ' ', ' ', ],
|
|
1047
|
+
[' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'LD', ' ', ' ', ' ', ' ', ],
|
|
1048
|
+
[' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ],
|
|
1049
|
+
[' ', ' ', ' ', ' ', ' ', 'LD', 'UD', 'DR', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ],
|
|
1050
|
+
['DR', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ],
|
|
1051
|
+
[' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'DR', ' ', ' ', ],
|
|
1052
|
+
[' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'DR', ' ', ' ', ' ', ' ', ' ', ' ', ],
|
|
1053
|
+
[' ', ' ', 'UL', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ],
|
|
1054
|
+
[' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'LR', ' ', ' ', ' ', ' ', ],
|
|
1055
|
+
[' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'LD', ' ', ' ', ' ', 'UD', ],
|
|
1056
|
+
[' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'UR', ' ', ' ', ' ', ' ', 'UD', 'UD', ],
|
|
1057
|
+
[' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'LR', ' ', ' ', ' ', ' ', ' ', ],
|
|
1058
|
+
['UL', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'LR', 'LR', ' ', ' ', ' ', ],
|
|
1059
|
+
[' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ],
|
|
1060
|
+
[' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'DR', ' ', ],
|
|
1061
|
+
])
|
|
1062
|
+
side = np.array([9, 7, 7, 7, 11, 10, 9, 8, 9, 10, 7, 9, 9, 2, 2])
|
|
1063
|
+
top = np.array([6, 5, 7, 3, 3, 2, 7, 8, 13, 8, 9, 8, 10, 13, 14])
|
|
1064
|
+
binst = solver.Board(board=board, top=top, side=side)
|
|
1065
|
+
solutions = binst.solve_and_print()
|
|
1066
|
+
```
|
|
1067
|
+
**Script Output**
|
|
1068
|
+
```python
|
|
1069
|
+
Solution found
|
|
1070
|
+
0 0 0 0 0 0 0 0 0 0 1 1 1 1 1
|
|
1071
|
+
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4
|
|
1072
|
+
|
|
1073
|
+
0 . . . . . . ┌───────────────────────┐ ┌───┐
|
|
1074
|
+
│ │ │ │
|
|
1075
|
+
1 . . . . . . │ . ┌───────┐ . └───┘ │
|
|
1076
|
+
│ │ │ │
|
|
1077
|
+
2 . . . . . . │ . │ . └───────────────┘
|
|
1078
|
+
│ │
|
|
1079
|
+
3 . . ┌───┐ ┌───┐ │ ┌───┘ . . . . . .
|
|
1080
|
+
│ │ │ │ │ │
|
|
1081
|
+
4 ┌───────┘ │ │ └───┘ └───┐ . . . . ┌───┐
|
|
1082
|
+
│ │ │ │ │ │
|
|
1083
|
+
5 └───────┐ └───┘ . . ┌───┘ . . . ┌───┘ │
|
|
1084
|
+
│ │ │ │
|
|
1085
|
+
6 . . │ . . . ┌───┘ ┌───────────────┘ . │
|
|
1086
|
+
│ │ │ │
|
|
1087
|
+
7 . ┌───┘ . . . └───────┘ . . . ┌───────┘
|
|
1088
|
+
│ │
|
|
1089
|
+
8 . └───┐ . . . . . ┌───────────┐ │ ┌───┐
|
|
1090
|
+
│ │ │ │ │ │
|
|
1091
|
+
9 ┌───────┘ . . . . . │ ┌───┐ └───┘ │ │
|
|
1092
|
+
│ │ │ │ │ │
|
|
1093
|
+
10 │ . . . . . . . └───┘ └───┐ . │ │
|
|
1094
|
+
│ │ │ │
|
|
1095
|
+
11 │ . . . . . . ┌───────────────┘ ┌───┘ │
|
|
1096
|
+
│ │ │ │
|
|
1097
|
+
12──┘ . . . . . . └───────────────────┘ ┌───┘
|
|
1098
|
+
│
|
|
1099
|
+
13 . . . . . . . . . . . . . └───┐
|
|
1100
|
+
│
|
|
1101
|
+
14 . . . . . . . . . . . . . ┌───┘
|
|
1102
|
+
│
|
|
1103
|
+
Solutions found: 1
|
|
1104
|
+
status: OPTIMAL
|
|
1105
|
+
Time taken: 1.01 seconds
|
|
1106
|
+
```
|
|
1107
|
+
|
|
1108
|
+
**Solved puzzle**
|
|
1109
|
+
|
|
1110
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/tracks_solved.png" alt="Tracks solved" width="500">
|
|
1111
|
+
|
|
1112
|
+
---
|
|
1113
|
+
|
|
1114
|
+
## Pearl (Puzzle Type #19)
|
|
1115
|
+
|
|
1116
|
+
Also known as Masyu
|
|
1117
|
+
|
|
1118
|
+
* [**Play online**](https://www.chiark.greenend.org.uk/~sgtatham/puzzles/js/pearl.html)
|
|
1119
|
+
|
|
1120
|
+
* [**Instructions**](https://www.chiark.greenend.org.uk/~sgtatham/puzzles/doc/pearl.html#pearl)
|
|
1121
|
+
|
|
1122
|
+
* [**Solver Code**](https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/pearl)
|
|
1123
|
+
|
|
1124
|
+
<details>
|
|
1125
|
+
<summary><strong>Rules</strong></summary>
|
|
1126
|
+
|
|
1127
|
+
You have a grid of squares. Your job is to draw lines between the centres of horizontally or vertically adjacent squares, so that the lines form a single closed loop. In the resulting grid, some of the squares that the loop passes through will contain corners, and some will be straight horizontal or vertical lines. (And some squares can be completely empty – the loop doesn't have to pass through every square.)
|
|
1128
|
+
|
|
1129
|
+
Some of the squares contain black and white circles, which are clues that the loop must satisfy.
|
|
1130
|
+
|
|
1131
|
+
A black circle in a square indicates that that square is a corner, but neither of the squares adjacent to it in the loop is also a corner.
|
|
1132
|
+
|
|
1133
|
+
A white circle indicates that the square is a straight edge, but at least one of the squares adjacent to it in the loop is a corner.
|
|
1134
|
+
|
|
1135
|
+
(In both cases, the clue only constrains the two squares adjacent in the loop, that is, the squares that the loop passes into after leaving the clue square. The squares that are only adjacent in the grid are not constrained.)
|
|
1136
|
+
|
|
1137
|
+
</details>
|
|
1138
|
+
|
|
1139
|
+
**Unsolved puzzle**
|
|
1140
|
+
|
|
1141
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/pearl_unsolved.png" alt="Pearl unsolved" width="500">
|
|
1142
|
+
|
|
1143
|
+
Code to utilize this package and solve the puzzle:
|
|
1144
|
+
```python
|
|
1145
|
+
import numpy as np
|
|
1146
|
+
from puzzle_solver import pearl_solver as solver
|
|
1147
|
+
board = np.array([
|
|
1148
|
+
['B', ' ', ' ', 'W', ' ', ' ', 'W', ' ', 'B', ' ', ' ', 'B'],
|
|
1149
|
+
[' ', ' ', ' ', 'B', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '],
|
|
1150
|
+
[' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'B', ' ', ' ', ' '],
|
|
1151
|
+
[' ', 'B', ' ', 'B', ' ', 'W', ' ', 'B', ' ', 'B', 'W', ' '],
|
|
1152
|
+
[' ', ' ', 'B', ' ', 'B', ' ', ' ', ' ', ' ', ' ', ' ', ' '],
|
|
1153
|
+
[' ', ' ', ' ', ' ', ' ', ' ', ' ', 'W', 'W', ' ', ' ', 'B'],
|
|
1154
|
+
[' ', ' ', 'B', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '],
|
|
1155
|
+
['B', ' ', ' ', ' ', ' ', 'B', 'B', ' ', ' ', ' ', ' ', 'B'],
|
|
1156
|
+
])
|
|
1157
|
+
binst = solver.Board(board)
|
|
1158
|
+
solutions = binst.solve_and_print()
|
|
1159
|
+
```
|
|
1160
|
+
**Script Output**
|
|
1161
|
+
```python
|
|
1162
|
+
Solution found
|
|
1163
|
+
0 0 0 0 0 0 0 0 0 0 1 1
|
|
1164
|
+
0 1 2 3 4 5 6 7 8 9 0 1
|
|
1165
|
+
|
|
1166
|
+
0 B───────────W───┐ ┌───W───┐ B───────────B
|
|
1167
|
+
│ │ │ │ │ │
|
|
1168
|
+
1 │ ┌───────B └───┘ ┌───┘ │ ┌───┐ │
|
|
1169
|
+
│ │ │ │ │ │ │ │
|
|
1170
|
+
2 └───┘ . │ ┌───┐ └───────B │ │ │
|
|
1171
|
+
│ │ │ │ │ │
|
|
1172
|
+
3 . B───────B │ W . B───────B W │
|
|
1173
|
+
│ │ │ │ │ │
|
|
1174
|
+
4 . │ B───────B └───┐ │ ┌───┐ └───┘
|
|
1175
|
+
│ │ │ │ │ │
|
|
1176
|
+
5 ┌───┘ │ . ┌───┐ │ W W └───────B
|
|
1177
|
+
│ │ │ │ │ │ │ │
|
|
1178
|
+
6 │ . B───────┘ │ │ └───┘ . . │
|
|
1179
|
+
│ │ │ │
|
|
1180
|
+
7 B───────────────────B B───────────────────B
|
|
1181
|
+
|
|
1182
|
+
Solutions found: 1
|
|
1183
|
+
status: OPTIMAL
|
|
1184
|
+
Time taken: 0.12 seconds
|
|
1185
|
+
```
|
|
1186
|
+
|
|
1187
|
+
**Solved puzzle**
|
|
1188
|
+
|
|
1189
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/pearl_solved.png" alt="Pearl solved" width="500">
|
|
1190
|
+
|
|
1191
|
+
---
|
|
1192
|
+
|
|
1193
|
+
## Inertia (Puzzle Type #21)
|
|
1194
|
+
|
|
1195
|
+
This solver is a bit different from the other solvers in this repo because this game does not have a unique solution (you simply move the ball to collect all the gems).
|
|
1196
|
+
|
|
1197
|
+
Thus the solver was developed with the additional much harder goal of collecting all the gems with the least number of moves.
|
|
1198
|
+
|
|
1199
|
+
It does so using the following high level steps:
|
|
1200
|
+
|
|
1201
|
+
1. Model the board as a directed graph where the cells are nodes and legal moves as directed edges with unit cost. Each gem has to a group of edges where traversing any one of them collects that gem.
|
|
1202
|
+
2. Model step (1) as a [Generalized Traveling Salesman Problem (GTSP)](https://en.wikipedia.org/wiki/Set_TSP_problem), where each gem's edge group forms a cluster.
|
|
1203
|
+
3. Apply the [Noon–Bean transformation](https://deepblue.lib.umich.edu/bitstream/handle/2027.42/6834/ban3102.0001.001.pdf?sequence=5) **(Noon & Bean, 1991)** to convert the GTSP from step (2) into an equivalent Asymmetric TSP (ATSP) that can be solved with OR-Tools' routing solver. (Noon-Bean transformation is mentioned but not described in the [TSP wikipedia page](https://en.wikipedia.org/wiki/Travelling_salesman_problem).)
|
|
1204
|
+
4. Use a [Vehicle Routing Problem (VRP)](https://en.wikipedia.org/wiki/Vehicle_routing_problem) solver using the [OR-Tools VRP solver](https://developers.google.com/optimization/routing/routing_tasks) to solve the ATSP.
|
|
1205
|
+
|
|
1206
|
+
This achieves a final sequence of moves that is empirically always faster than the website's solution.
|
|
1207
|
+
|
|
1208
|
+
* [**Play online**](https://www.chiark.greenend.org.uk/~sgtatham/puzzles/js/inertia.html)
|
|
1209
|
+
|
|
1210
|
+
* [**Instructions**](https://www.chiark.greenend.org.uk/~sgtatham/puzzles/doc/inertia.html#inertia)
|
|
1211
|
+
|
|
1212
|
+
* [**Solver Code**](https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/inertia)
|
|
1213
|
+
|
|
1214
|
+
<details>
|
|
1215
|
+
<summary><strong>Rules</strong></summary>
|
|
1216
|
+
|
|
1217
|
+
You are a small green ball sitting in a grid full of obstacles. Your aim is to collect all the gems without running into any mines.
|
|
1218
|
+
|
|
1219
|
+
You can move the ball in any orthogonal or diagonal direction. Once the ball starts moving, it will continue until something stops it. A wall directly in its path will stop it (but if it is moving diagonally, it will move through a diagonal gap between two other walls without stopping). Also, some of the squares are ‘stops’; when the ball moves on to a stop, it will stop moving no matter what direction it was going in. Gems do not stop the ball; it picks them up and keeps on going.
|
|
1220
|
+
|
|
1221
|
+
Running into a mine is fatal. Even if you picked up the last gem in the same move which then hit a mine, the game will count you as dead rather than victorious.
|
|
1222
|
+
|
|
1223
|
+
</details>
|
|
1224
|
+
|
|
1225
|
+
**Unsolved puzzle**
|
|
1226
|
+
|
|
1227
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/inertia_unsolved.png" alt="Inertia unsolved" width="500">
|
|
1228
|
+
|
|
1229
|
+
Code to utilize this package and solve the puzzle:
|
|
1230
|
+
|
|
1231
|
+
(Note: there is a script that parses a screenshot of the board and outputs the below array that the solver uses. The script uses classical computer vision techniques and is called `parse_map.py`)
|
|
1232
|
+
```python
|
|
1233
|
+
import numpy as np
|
|
1234
|
+
from puzzle_solver import inertia_solver as solver
|
|
1235
|
+
board = np.array([
|
|
1236
|
+
['O', 'O', 'M', ' ', 'G', 'O', 'G', 'O', ' ', ' ', 'M', ' ', ' ', 'O', 'G', 'G', 'W', 'O', 'O', 'O'],
|
|
1237
|
+
['O', ' ', 'W', ' ', 'W', 'O', 'G', 'M', ' ', ' ', ' ', 'G', 'M', 'O', 'W', 'G', ' ', 'M', 'M', 'O'],
|
|
1238
|
+
['O', 'M', 'O', 'O', ' ', 'M', ' ', 'W', 'W', 'M', 'G', 'W', ' ', ' ', 'G', ' ', 'W', 'G', 'O', 'G'],
|
|
1239
|
+
['O', ' ', 'O', 'M', 'G', 'O', 'W', 'G', 'M', 'O', ' ', ' ', 'G', 'G', 'G', ' ', 'M', 'W', 'M', 'O'],
|
|
1240
|
+
['M', 'M', 'O', 'G', ' ', 'W', ' ', ' ', 'O', 'G', ' ', 'M', 'M', ' ', 'W', 'W', ' ', 'W', 'W', 'O'],
|
|
1241
|
+
['G', ' ', 'G', 'W', 'M', 'W', 'W', ' ', 'G', 'G', 'W', 'M', 'G', 'G', ' ', 'G', 'O', 'O', 'M', 'M'],
|
|
1242
|
+
['M', ' ', 'M', ' ', 'W', 'W', 'M', 'M', 'M', 'O', 'M', 'G', 'O', 'M', 'M', 'W', 'B', 'O', 'W', 'M'],
|
|
1243
|
+
['G', 'G', ' ', 'W', 'M', 'M', 'W', 'O', 'W', 'G', 'W', 'O', 'O', 'M', ' ', 'W', 'W', 'G', 'G', 'M'],
|
|
1244
|
+
[' ', 'M', 'M', ' ', ' ', ' ', 'G', 'G', 'M', 'O', 'M', 'O', 'M', 'G', 'W', 'M', 'W', ' ', 'O', ' '],
|
|
1245
|
+
['G', ' ', 'M', ' ', ' ', ' ', 'W', 'O', 'W', 'W', 'M', 'M', 'G', 'W', ' ', ' ', 'W', 'M', 'G', 'W'],
|
|
1246
|
+
['G', 'O', 'M', 'M', 'G', 'M', 'W', 'O', 'O', 'G', 'W', 'M', 'M', 'G', 'G', ' ', 'O', ' ', 'W', 'W'],
|
|
1247
|
+
['G', 'G', 'W', 'G', 'M', ' ', 'G', 'W', 'W', ' ', 'G', ' ', 'O', 'W', 'G', 'G', 'O', ' ', 'M', 'M'],
|
|
1248
|
+
['W', 'M', 'O', ' ', 'W', 'O', 'O', 'M', 'M', 'O', 'G', 'W', ' ', 'G', 'O', 'G', 'G', 'O', 'O', 'W'],
|
|
1249
|
+
['W', 'W', 'W', ' ', 'W', 'O', 'W', 'M', 'O', 'M', 'G', 'O', 'O', ' ', ' ', 'W', 'W', 'G', 'W', 'W'],
|
|
1250
|
+
['O', 'W', 'O', 'M', 'O', 'G', ' ', 'O', 'O', 'M', 'O', ' ', 'M', 'M', 'O', 'G', 'W', 'G', 'M', ' '],
|
|
1251
|
+
['M', 'G', 'O', 'G', 'O', 'G', 'O', 'G', ' ', 'W', 'W', 'G', 'O', ' ', 'W', 'M', 'G', ' ', 'W', ' ']
|
|
1252
|
+
])
|
|
1253
|
+
start_pos, edges, edges_to_direction, gems_to_edges = solver.parse_nodes_and_edges(board)
|
|
1254
|
+
optimal_walk = solver.solve_optimal_walk(start_pos, edges, gems_to_edges)
|
|
1255
|
+
moves = solver.get_moves_from_walk(optimal_walk, edges_to_direction, verbose=True)
|
|
1256
|
+
```
|
|
1257
|
+
**Script Output**
|
|
1258
|
+
|
|
1259
|
+
Note that the output is the sequence of moves to collect all the gems. This particular solution is 106 moves, which is 15 moves better than the website's solution.
|
|
1260
|
+
```python
|
|
1261
|
+
number of moves 106
|
|
1262
|
+
↗ ↖ ↖ ↙ ↙ ↖ ↖ ↙ → ↘
|
|
1263
|
+
↙ → ↖ → ↙ ↓ → ↘ ↗ ↓
|
|
1264
|
+
↘ → ↘ ↓ ↗ ↓ ↑ → ↗ ↖
|
|
1265
|
+
↑ ↗ ↑ ↗ → ↓ ← ↙ ↖ ↗
|
|
1266
|
+
↓ ↙ ↙ ↑ ← ↘ ↙ ↓ → ↘
|
|
1267
|
+
↘ ↙ ↖ ↙ ↗ ↘ ↗ ↘ ↑ ↘
|
|
1268
|
+
↖ ↑ ↗ → → ↘ → ↘ ↗ ↑
|
|
1269
|
+
← ↑ ↖ ↖ ↗ → ↘ ↓ ↖ ←
|
|
1270
|
+
↖ ↓ ← ↓ ↓ ↑ ↖ → ↗ ↗
|
|
1271
|
+
↘ ↘ ↙ ↘ ↓ ↗ ↖ ↘ ↙ ←
|
|
1272
|
+
↘ ↖ ↗ ↑ ↗ →
|
|
1273
|
+
Time taken: 13.92 seconds
|
|
1274
|
+
```
|
|
1275
|
+
|
|
1276
|
+
**Solved puzzle**
|
|
1277
|
+
|
|
1278
|
+
This picture won't mean much as the game is about the sequence of moves not the final frame as shown here.
|
|
1279
|
+
|
|
1280
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/inertia_solved.png" alt="Inertia solved" width="500">
|
|
1281
|
+
|
|
1282
|
+
---
|
|
1283
|
+
|
|
1284
|
+
## Guess (Puzzle Type #22)
|
|
1285
|
+
|
|
1286
|
+
* [**Play online**](https://www.chiark.greenend.org.uk/~sgtatham/puzzles/js/guess.html)
|
|
1287
|
+
|
|
1288
|
+
* [**Instructions**](https://www.chiark.greenend.org.uk/~sgtatham/puzzles/doc/guess.html#guess)
|
|
1289
|
+
|
|
1290
|
+
* [**Solver Code**](https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/guess)
|
|
1291
|
+
|
|
1292
|
+
<details>
|
|
1293
|
+
<summary><strong>Rules</strong></summary>
|
|
1294
|
+
|
|
1295
|
+
You have a set of coloured pegs, and have to reproduce a predetermined sequence of them (chosen by the computer) within a certain number of guesses.
|
|
1296
|
+
|
|
1297
|
+
Each guess gets marked with the number of correctly-coloured pegs in the correct places (in black), and also the number of correctly-coloured pegs in the wrong places (in white).
|
|
1298
|
+
|
|
1299
|
+
</details>
|
|
1300
|
+
|
|
1301
|
+
|
|
1302
|
+
Unlike most other puzzles in this repo, 'Guess' is very different. Similar to minesweeper, Guess is a limited information dynamic puzzle where the next best move depends on information revealed by previous moves (The similarities to minesweeper stop here).
|
|
1303
|
+
|
|
1304
|
+
The solver is designed to take the state of the board at any timestep and always gives the next optimal guess. This might seem like an impossible task at first but it's actually not too bad. The optimal guess is defined to be the one that maximizes the Shannon entropy (i.e. maximizes the expected information gain).
|
|
1305
|
+
|
|
1306
|
+
The steps below formaly describe the algorithm that is also used in [this amazing 3Blue1Brown video](https://www.youtube.com/watch?v=v68zYyaEmEA) on solving Wordle using information theory. Where 3Blue1Browne describes the same steps below but for a slightly harder problem to solve wordle (a very similar game). The video intuitively justifies this algorithm and builds it from scratch using basic intuition.
|
|
1307
|
+
|
|
1308
|
+
To formalize the algorithm, let's first define our three inputs as
|
|
1309
|
+
- $N :=$ the number of pegs (the length of every guess)
|
|
1310
|
+
- must have $N \geq 1$ and by default $N = 4$ in the game
|
|
1311
|
+
- $C :=$ the set of possible colors
|
|
1312
|
+
- what actually matters is $|C|$, the number of possible choices for each peg, i.e. the number of colors
|
|
1313
|
+
- by default in the game, $C = \{R,Y,G,B,O,P\}$ (six distinct symbols; only $|C|$ matters) for Red, Yellow, Green, Blue, Orange, and Purple.
|
|
1314
|
+
- $\mathrm{MR} := ((m_1, r_1), (m_2, r_2), ..., (m_k, r_k))$ be the sequence of previous guesses and results where $(m_i, r_i)$ is the previous guess and result at round $i$ and $k\geq 0$ is the number of previous guesses the player has made
|
|
1315
|
+
- Note that $m_i$ has length $N$ and each element is $\in C$ by definition
|
|
1316
|
+
- $r_i$ is a triplet of non-negative integers that sum to $N$ by definition. This corresponds to counts of exact-match positions, color-only matches, and non-matches (visualized as black, white, and grey dots)
|
|
1317
|
+
|
|
1318
|
+
The algorithm is as follows
|
|
1319
|
+
|
|
1320
|
+
1. Define $G$ as the set of every possible guess that can be made
|
|
1321
|
+
|
|
1322
|
+
$$G := \{(c_1, \dots, c_N) \mid \forall i \in \{1, \dots, N\},\ c_i \in C \}$$
|
|
1323
|
+
|
|
1324
|
+
1. Note that $|G| = |C|^N$
|
|
1325
|
+
|
|
1326
|
+
2. Note that $m_i \in G$ for all $i \in \{1, 2, ..., k\}$ by definition.
|
|
1327
|
+
|
|
1328
|
+
2. Define $T$ as the set of every possible result triplet
|
|
1329
|
+
|
|
1330
|
+
$$T := \{(t_1, t_2, t_3) \in \mathbb{N}_0^3 : t_1 + t_2 + t_3 = N\}$$
|
|
1331
|
+
|
|
1332
|
+
1. Note that $r_i \in T$ for all $i \in \{1, 2, ..., k\}$ by definition.
|
|
1333
|
+
2. Note that $|T|=\binom{N+2}{2}$ (stars-and-bars)
|
|
1334
|
+
3. By default, $N = 4$ in the game so $|T|=15$
|
|
1335
|
+
|
|
1336
|
+
3. Define $f : G \times G \to T$ by $f(g_{\text{guess}}, g_{\text{truth}}) = t$ as the result triplet $(t_1, t_2, t_3)$ obtained when guessing $g_{\text{guess}}$ against ground truth $g_{\text{truth}}$. It is trivial to algorithmically make this function which simply counts from $g_1$ and $g_2.$ Look at the function `get_triplets` for a naive implementation of this.
|
|
1337
|
+
|
|
1338
|
+
4. Define $S$ as the subset of $G$ that is consistent with the previous guesses $m_i$ and results $r_i$
|
|
1339
|
+
|
|
1340
|
+
$$
|
|
1341
|
+
S := \{g \in G : \forall i \in \{1, 2, ..., k\}, f(m_i, g) = r_i\}
|
|
1342
|
+
$$
|
|
1343
|
+
1. Note that if there aren't previous guesses ($\mathrm{MR} = \emptyset$) then $S = G$
|
|
1344
|
+
2. Note that if $S = \emptyset$ then something is wrong with the previous guesses $\mathrm{MR}$ and there is no possible solution to the puzzle. The algorithm stops here and informs the user that the puzzle is unsolvable with the given guesses $\mathrm{MR}$ and that this should never happen unless there is a typo in the guesses $\mathrm{MR}$ (which is usually the case).
|
|
1345
|
+
|
|
1346
|
+
5. For each possible guess $g \in G$ and each triplet $t \in T$, count the number of possible solutions $s \in S$ that result in the triplet $t$ when guessing $g$. i.e.
|
|
1347
|
+
|
|
1348
|
+
$$D(g, t) := |\{s \in S: f(g, s) = t\}|$$
|
|
1349
|
+
|
|
1350
|
+
6. Calculate the entropy for each possible guess $g \in G$ as the sum of probability times the self-information for every triplet $t \in T$. i.e.
|
|
1351
|
+
|
|
1352
|
+
$$H : G \to \mathbb{R}, \quad H(g) = -\sum_{t \in T} P(t \mid g) \log_2 P(t \mid g)$$
|
|
1353
|
+
|
|
1354
|
+
1. where $P(t \mid g) = \frac{D(g, t)}{|S|}$
|
|
1355
|
+
2. By convention, terms with $P(t \mid g)=0$ contribute $0$ to the sum (interpreting $0\log 0 := 0)$.
|
|
1356
|
+
|
|
1357
|
+
7. Return the guess $g \in G$ that maximizes the entropy $H(g)$ (to break ties, choose $g$ that is also in $S$ such that it's possibly the correct solution as well, break further ties arbitrarily).
|
|
1358
|
+
1. i.e. return any $g^*\in (\mathrm{argmax}_{g\in G}\ H(g) \cap S)$ if exists
|
|
1359
|
+
2. otherwise return any $g\in \mathrm{argmax}_{g\in G}\ H(g)$.
|
|
1360
|
+
|
|
1361
|
+
|
|
1362
|
+
If you are at all interested in the above steps and want to understand more,
|
|
1363
|
+
I highly recommend watching [this amazing 3Blue1Brown video](https://www.youtube.com/watch?v=v68zYyaEmEA) on solving Wordle using information theory where he describes the same steps but a bits more complicated problem to solve Wordle (a very similar game).
|
|
1364
|
+
|
|
1365
|
+
Below is an example of how to utilize the solver while in the middle of a puzzle.
|
|
1366
|
+
|
|
1367
|
+
(This is the only solver that under the hood does not utilize any packages besides numpy)
|
|
1368
|
+
|
|
1369
|
+
**Unsolved puzzle**
|
|
1370
|
+
|
|
1371
|
+
Let's say we start and made two guesses to end up with the following puzzle:
|
|
1372
|
+
|
|
1373
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/guess_1.png" alt="Guess Pre Move" width="500">
|
|
1374
|
+
|
|
1375
|
+
Code to utilize this package and solve the puzzle:
|
|
1376
|
+
|
|
1377
|
+
We encode the puzzle as a Board object then retrieve the optimal next guess:
|
|
1378
|
+
```python
|
|
1379
|
+
from puzzle_solver import guess_solver as solver
|
|
1380
|
+
binst = solver.Board()
|
|
1381
|
+
binst.add_guess(('R', 'Y', 'G', 'B'), (1, 1, 2)) # 1 black dot, 1 white dot, 2 grey dots
|
|
1382
|
+
binst.add_guess(('R', 'G', 'O', 'P'), (0, 2, 2)) # 0 black dots, 2 white dots, 2 grey dots
|
|
1383
|
+
binst.best_next_guess()
|
|
1384
|
+
```
|
|
1385
|
+
|
|
1386
|
+
Note: the three numbers in each guess is the result of the guess: (# of black dots, # of white dots, # of grey dots)
|
|
1387
|
+
|
|
1388
|
+
Note: by default, the board will have 4 circles and 6 possible colors (R: Red, Y: Yellow, G: Green, B: Blue, O: Orange, P: Purple) but both of these are optional parameters to the Board to change behavior.
|
|
1389
|
+
|
|
1390
|
+
**Script Output 1/2**
|
|
1391
|
+
|
|
1392
|
+
Note that the output is next optimal guess that has the maximum Shannon entropy.
|
|
1393
|
+
```python
|
|
1394
|
+
out of 1296 possible ground truths, only 57 are still possible.
|
|
1395
|
+
max entropy guess is: ['P', 'Y', 'Y', 'G'] with entropy 3.4511
|
|
1396
|
+
```
|
|
1397
|
+
|
|
1398
|
+
So we make our next guess as (Purple, Yellow, Yellow, Green) and let's say we get this result: (2 black, 1 white, 1 grey)
|
|
1399
|
+
|
|
1400
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/guess_2.png" alt="Guess Post 1 Move" width="500">
|
|
1401
|
+
|
|
1402
|
+
So we input that again to the solver to retrieve the next optimal guess:
|
|
1403
|
+
|
|
1404
|
+
```python
|
|
1405
|
+
from puzzle_solver import guess_solver as solver
|
|
1406
|
+
binst = solver.Board()
|
|
1407
|
+
binst.add_guess(('R', 'Y', 'G', 'B'), (1, 1, 2)) # 1 black dot, 1 white dot, 2 grey dots
|
|
1408
|
+
binst.add_guess(('R', 'G', 'O', 'P'), (0, 2, 2)) # 0 black dots, 2 white dots, 2 grey dots
|
|
1409
|
+
binst.add_guess(('P', 'Y', 'Y', 'G'), (2, 1, 1)) # 2 black dots, 1 white dot, 1 grey dot
|
|
1410
|
+
binst.best_next_guess()
|
|
1411
|
+
```
|
|
1412
|
+
|
|
1413
|
+
**Script Output 2/2**
|
|
1414
|
+
|
|
1415
|
+
```python
|
|
1416
|
+
out of 1296 possible ground truths, only 3 are still possible.
|
|
1417
|
+
max entropy guess is: ['G', 'Y', 'Y', 'O'] with entropy 1.5850
|
|
1418
|
+
```
|
|
1419
|
+
|
|
1420
|
+
So we make our fourth guess as (Green, Yellow, Yellow, Orange)
|
|
1421
|
+
|
|
1422
|
+
When we input the guess, we see that we correctly solve the puzzle!
|
|
1423
|
+
|
|
1424
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/guess_3.png" alt="Guess Post 2 Moves" width="500">
|
|
1425
|
+
|
|
1426
|
+
Note that in this case, the correct guess was among multiple possible guesses
|
|
1427
|
+
|
|
1428
|
+
In the case when there's only one possible choice left, the solver will inform you that it's the garunteed solution.
|
|
1429
|
+
|
|
1430
|
+
---
|
|
1431
|
+
|
|
1432
|
+
## Chess Melee (Puzzle Type #25)
|
|
1433
|
+
|
|
1434
|
+
* [**Play online**](https://www.puzzle-chess.com/chess-melee-13/)
|
|
1435
|
+
|
|
1436
|
+
* [**Solver Code**](https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/chess_range#chess-melee-puzzle-type-25)
|
|
1437
|
+
|
|
1438
|
+
<details>
|
|
1439
|
+
<summary><strong>Rules</strong></summary>
|
|
1440
|
+
|
|
1441
|
+
You are given a chess board with $N$ pieces distributed on it (equal white and black pieces, one more black if $N$ is odd). Your aim is to make $N-1$ sequence of moves where each move is a legal chess move and captures another piece of the opposite color and end up with a single piece on the board. White starts and colors alternate as usual.
|
|
1442
|
+
|
|
1443
|
+
- Pieces move as standard chess pieces.
|
|
1444
|
+
- White moves first.
|
|
1445
|
+
- You can perform only capture moves. A move that does not capture another piece of the opposite color is not allowed.
|
|
1446
|
+
- The goal is to end up with one single piece on the board.
|
|
1447
|
+
|
|
1448
|
+
</details>
|
|
1449
|
+
|
|
1450
|
+
**Unsolved puzzle**
|
|
1451
|
+
|
|
1452
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/chess_melee_unsolved.png" alt="Chess melee unsolved" width="500">
|
|
1453
|
+
|
|
1454
|
+
Code to utilize this package and solve the puzzle:
|
|
1455
|
+
|
|
1456
|
+
(Note that this puzzle does not typically have a unique solution. Thus, we specify here that we only want the first valid solution that the solver finds.)
|
|
1457
|
+
|
|
1458
|
+
```python
|
|
1459
|
+
from puzzle_solver import chess_melee_solver as solver
|
|
1460
|
+
# algebraic notation
|
|
1461
|
+
board = ['Pb7', 'Nc7', 'Bc6', 'Ne6', 'Pb5', 'Rc4', 'Qb3', 'Rf7', 'Rb6', 'Pe5', 'Nc3', 'Pd3', 'Nf3']
|
|
1462
|
+
colors = ['B', 'B', 'B', 'B', 'B', 'B', 'B', 'W', 'W', 'W', 'W', 'W', 'W']
|
|
1463
|
+
binst = solver.Board(board, colors)
|
|
1464
|
+
solutions = binst.solve_and_print()
|
|
1465
|
+
```
|
|
1466
|
+
**Script Output**
|
|
1467
|
+
|
|
1468
|
+
The output is in the form of "pos -> pos" where "pos" is the algebraic notation of the position.
|
|
1469
|
+
|
|
1470
|
+
```python
|
|
1471
|
+
Solution found
|
|
1472
|
+
['Rf7->Nc7', 'Ne6->Rc7', 'Pd3->Rc4', 'Qb3->Nc3', 'Pc4->Pb5', 'Qc3->Pe5', 'Nf3->Qe5', 'Nc7->Pb5', 'Ne5->Bc6', 'Pb7->Nc6', 'Rb6->Nb5', 'Pc6->Rb5']
|
|
1473
|
+
Solutions found: 1
|
|
1474
|
+
status: OPTIMAL
|
|
1475
|
+
Time taken: 6.24 seconds
|
|
1476
|
+
```
|
|
1477
|
+
|
|
1478
|
+
**Solved puzzle**
|
|
1479
|
+
|
|
1480
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/chess_melee_solved.png" alt="Chess melee solved" width="500">
|
|
1481
|
+
|
|
1482
|
+
---
|
|
1483
|
+
|
|
1484
|
+
## Aquarium (Puzzle Type #27)
|
|
1485
|
+
|
|
1486
|
+
* [**Play online**](https://www.puzzle-aquarium.com/)
|
|
1487
|
+
|
|
1488
|
+
* [**Solver Code**](https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/aquarium)
|
|
1489
|
+
|
|
1490
|
+
<details>
|
|
1491
|
+
<summary><strong>Rules</strong></summary>
|
|
1492
|
+
|
|
1493
|
+
The puzzle is played on a rectangular grid divided into blocks called "aquariums"
|
|
1494
|
+
|
|
1495
|
+
You have to "fill" the aquariums with water up to a certain level or leave it empty.
|
|
1496
|
+
|
|
1497
|
+
The water level in each aquarium is one and the same across its full width
|
|
1498
|
+
|
|
1499
|
+
The numbers outside the grid show the number of filled cells horizontally and vertically.
|
|
1500
|
+
|
|
1501
|
+
</details>
|
|
1502
|
+
|
|
1503
|
+
**Unsolved puzzle**
|
|
1504
|
+
|
|
1505
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/aquarium_unsolved.png" alt="Aquarium unsolved" width="500">
|
|
1506
|
+
|
|
1507
|
+
Code to utilize this package and solve the puzzle:
|
|
1508
|
+
|
|
1509
|
+
```python
|
|
1510
|
+
import numpy as np
|
|
1511
|
+
from puzzle_solver import aquarium_solver as solver
|
|
1512
|
+
board = np.array([
|
|
1513
|
+
['01', '01', '01', '01', '02', '02', '02', '03', '03', '03', '03', '04', '05', '05', '05'],
|
|
1514
|
+
['01', '02', '02', '02', '02', '06', '07', '07', '03', '08', '03', '04', '04', '05', '09'],
|
|
1515
|
+
['01', '01', '02', '11', '06', '06', '06', '12', '12', '08', '13', '13', '13', '09', '09'],
|
|
1516
|
+
['01', '11', '11', '11', '14', '06', '06', '12', '12', '15', '15', '13', '09', '09', '09'],
|
|
1517
|
+
['01', '01', '11', '11', '14', '12', '12', '12', '16', '16', '15', '13', '13', '17', '09'],
|
|
1518
|
+
['45', '11', '11', '14', '14', '12', '42', '42', '42', '15', '15', '13', '13', '17', '18'],
|
|
1519
|
+
['45', '11', '11', '14', '14', '12', '12', '43', '15', '15', '20', '13', '13', '17', '18'],
|
|
1520
|
+
['46', '46', '11', '19', '19', '19', '43', '43', '44', '20', '20', '20', '13', '17', '18'],
|
|
1521
|
+
['46', '22', '23', '23', '23', '19', '43', '21', '21', '24', '24', '24', '25', '17', '17'],
|
|
1522
|
+
['22', '22', '22', '23', '19', '19', '26', '24', '24', '24', '28', '28', '25', '17', '33'],
|
|
1523
|
+
['22', '22', '23', '23', '27', '27', '26', '26', '24', '24', '29', '29', '25', '25', '33'],
|
|
1524
|
+
['22', '22', '35', '27', '27', '26', '26', '26', '26', '30', '30', '30', '25', '34', '34'],
|
|
1525
|
+
['37', '22', '35', '35', '35', '35', '35', '26', '26', '30', '31', '31', '32', '32', '40'],
|
|
1526
|
+
['37', '37', '37', '36', '36', '35', '26', '26', '26', '40', '40', '40', '40', '40', '40'],
|
|
1527
|
+
['37', '37', '37', '37', '35', '35', '38', '38', '39', '39', '40', '40', '40', '41', '41'],
|
|
1528
|
+
])
|
|
1529
|
+
top = np.array([6, 6, 5, 3, 3, 4, 7, 6, 9, 6, 3, 4, 9, 6, 7])
|
|
1530
|
+
side = np.array([3, 5, 1, 2, 5, 3, 10, 10, 5, 3, 7, 3, 7, 8, 12])
|
|
1531
|
+
binst = solver.Board(board=board, top=top, side=side)
|
|
1532
|
+
solutions = binst.solve_and_print()
|
|
1533
|
+
```
|
|
1534
|
+
**Script Output**
|
|
1535
|
+
|
|
1536
|
+
```python
|
|
1537
|
+
Solution found
|
|
1538
|
+
0 0 0 0 0 0 0 0 0 0 1 1 1 1 1
|
|
1539
|
+
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4
|
|
1540
|
+
┌───────────────┬───────────┬───────────────┬───┬───────────┐
|
|
1541
|
+
0│ │ │ │ │ O O O │
|
|
1542
|
+
│ ┌───────────┘ ┌───┬───┴───┐ ┌───┐ │ └───┐ ┌───┤
|
|
1543
|
+
1│ │ │ │ │ O │ │ O │ O O │ O │ │
|
|
1544
|
+
│ └───┐ ┌───┬───┘ └───┬───┴───┤ ├───┴───────┼───┘ │
|
|
1545
|
+
2│ │ │ │ │ │ O │ │ │
|
|
1546
|
+
│ ┌───┴───┘ ├───┐ │ ├───┴───┐ ┌───┘ │
|
|
1547
|
+
3│ │ │ │ O O │ │ │ │ │
|
|
1548
|
+
│ └───┐ │ ├───────┘ ┌───┴───┐ │ └───┬───┐ │
|
|
1549
|
+
4│ O O │ │ │ │ O O │ │ │ │ O │
|
|
1550
|
+
├───┬───┘ ┌───┘ │ ┌───────┴───┬───┘ │ │ ├───┤
|
|
1551
|
+
5│ │ │ │ │ O O O │ │ │ │ │
|
|
1552
|
+
│ │ │ │ └───┬───┬───┘ ┌───┤ │ │ │
|
|
1553
|
+
6│ O │ O O │ │ O O │ │ O O │ │ O O │ │ O │
|
|
1554
|
+
├───┴───┐ ├───────┴───┬───┘ ├───┬───┘ └───┐ │ │ │
|
|
1555
|
+
7│ O O │ O │ │ O O │ │ O O O │ O │ │ O │
|
|
1556
|
+
│ ┌───┼───┴───────┐ │ ┌───┴───┼───────────┼───┤ └───┤
|
|
1557
|
+
8│ O │ │ │ │ O │ O O │ │ O │ │
|
|
1558
|
+
├───┘ └───┐ ┌───┘ ├───┼───────┘ ┌───────┤ │ ┌───┤
|
|
1559
|
+
9│ │ │ O O │ │ │ │ O │ │ │
|
|
1560
|
+
│ ┌───┘ ├───────┤ └───┐ ├───────┤ └───┤ │
|
|
1561
|
+
10│ │ O O │ │ │ O O │ │ O O │ O │
|
|
1562
|
+
│ ├───┬───┘ ┌───┘ └───┬───┴───────┤ ┌───┴───┤
|
|
1563
|
+
11│ │ │ │ │ │ O │ O O │
|
|
1564
|
+
├───┐ │ └───────┴───────┐ │ ┌───────┼───┴───┬───┤
|
|
1565
|
+
12│ │ O │ │ O O │ │ O O │ O O │ │
|
|
1566
|
+
│ └───┴───┬───────┐ ┌───┘ ├───┴───────┴───────┘ │
|
|
1567
|
+
13│ O O O │ O O │ │ O O O │ │
|
|
1568
|
+
│ └───┬───┘ ├───────┬───┴───┐ ┌───────┤
|
|
1569
|
+
14│ O O O O │ O O │ O O │ O O │ │ O O │
|
|
1570
|
+
└───────────────┴───────┴───────┴───────┴───────────┴───────┘
|
|
1571
|
+
Solutions found: 1
|
|
1572
|
+
status: OPTIMAL
|
|
1573
|
+
Time taken: 0.02 seconds
|
|
1574
|
+
```
|
|
1575
|
+
|
|
1576
|
+
**Solved puzzle**
|
|
1577
|
+
|
|
1578
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/aquarium_solved.png" alt="Aquarium solved" width="500">
|
|
1579
|
+
|
|
1580
|
+
---
|
|
1581
|
+
|
|
1582
|
+
## Stitches (Puzzle Type #28)
|
|
1583
|
+
|
|
1584
|
+
* [**Play online**](https://www.puzzle-stitches.com/)
|
|
1585
|
+
|
|
1586
|
+
* [**Solver Code**](https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/stitches)
|
|
1587
|
+
|
|
1588
|
+
<details>
|
|
1589
|
+
<summary><strong>Rules</strong></summary>
|
|
1590
|
+
|
|
1591
|
+
- Connect each block with ALL its neighbor blocks with exactly 1 "stitch" each.
|
|
1592
|
+
- A "stitch" connects 2 orthogonally adjacent cells from different blocks.
|
|
1593
|
+
- 2 stitches cannot share a hole.
|
|
1594
|
+
- The clues outside the grid indicate the number of holes on that row/column
|
|
1595
|
+
- For 2÷ puzzles, you have to use 2 stitches to connect neighbor blocks, for 3÷ puzzles - 3 stitches etc.
|
|
1596
|
+
|
|
1597
|
+
</details>
|
|
1598
|
+
|
|
1599
|
+
**Unsolved puzzle**
|
|
1600
|
+
|
|
1601
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/stitches_unsolved.png" alt="Stitches unsolved" width="500">
|
|
1602
|
+
|
|
1603
|
+
Code to utilize this package and solve the puzzle:
|
|
1604
|
+
|
|
1605
|
+
```python
|
|
1606
|
+
import numpy as np
|
|
1607
|
+
from puzzle_solver import stitches_solver as solver
|
|
1608
|
+
board = np.array([
|
|
1609
|
+
["00", "00", "00", "00", "00", "01", "01", "01", "01", "01", "01", "01", "01", "02", "02"],
|
|
1610
|
+
["00", "03", "03", "04", "00", "00", "01", "05", "05", "05", "05", "05", "01", "01", "02"],
|
|
1611
|
+
["00", "03", "04", "04", "04", "00", "05", "05", "05", "05", "05", "05", "05", "05", "02"],
|
|
1612
|
+
["00", "03", "04", "04", "04", "04", "05", "05", "06", "05", "02", "02", "02", "02", "02"],
|
|
1613
|
+
["07", "03", "03", "03", "03", "04", "06", "06", "06", "06", "06", "06", "06", "02", "02"],
|
|
1614
|
+
["07", "07", "07", "03", "03", "04", "04", "06", "08", "08", "08", "06", "02", "02", "02"],
|
|
1615
|
+
["07", "07", "03", "03", "03", "04", "04", "08", "08", "08", "08", "06", "06", "06", "02"],
|
|
1616
|
+
["07", "07", "07", "07", "07", "08", "08", "08", "09", "09", "08", "06", "08", "06", "02"],
|
|
1617
|
+
["10", "10", "07", "07", "09", "09", "09", "09", "09", "09", "08", "08", "08", "11", "02"],
|
|
1618
|
+
["10", "10", "07", "09", "09", "09", "09", "09", "09", "09", "09", "08", "08", "11", "02"],
|
|
1619
|
+
["10", "09", "09", "09", "12", "12", "12", "13", "09", "09", "11", "11", "11", "11", "11"],
|
|
1620
|
+
["10", "10", "10", "09", "12", "12", "12", "13", "09", "11", "11", "11", "13", "13", "11"],
|
|
1621
|
+
["14", "15", "10", "12", "12", "16", "17", "13", "13", "11", "13", "13", "13", "13", "11"],
|
|
1622
|
+
["14", "15", "10", "12", "16", "16", "17", "17", "13", "13", "13", "13", "13", "13", "11"],
|
|
1623
|
+
["14", "15", "15", "12", "16", "16", "17", "17", "17", "17", "17", "13", "13", "13", "13"]
|
|
1624
|
+
])
|
|
1625
|
+
top = np.array([6, 6, 9, 5, 3, 8, 9, 3, 1, 4, 4, 1, 4, 8, 5])
|
|
1626
|
+
side = np.array([0, 10, 6, 4, 4, 1, 5, 8, 2, 6, 5, 11, 4, 3, 7])
|
|
1627
|
+
binst = solver.Board(board=board, top=top, side=side)
|
|
1628
|
+
solutions = binst.solve_and_print()
|
|
1629
|
+
```
|
|
1630
|
+
|
|
1631
|
+
Note: `solver.Board` accepts an optional `connection_count=N` parameter to specify the (÷N) stitches puzzle (by default, 1 stitch).
|
|
1632
|
+
|
|
1633
|
+
**Script Output**
|
|
1634
|
+
|
|
1635
|
+
```python
|
|
1636
|
+
Solution found
|
|
1637
|
+
0 0 0 0 0 0 0 0 0 0 1 1 1 1 1
|
|
1638
|
+
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4
|
|
1639
|
+
┌───────────────────┬───────────────────────────────┬───────┐
|
|
1640
|
+
0│ . . . . . │ . . . . . . . . │ . . │
|
|
1641
|
+
│ ┌───────┬───┐ └───┐ ┌───────────────────┐ └───┐ │
|
|
1642
|
+
1│ O─┼─O O │ O─┼─O O─┼─O │ . . . . . │ O O─┼─O │
|
|
1643
|
+
│ │ ┌─┼─┘ └───┐ ├───┘ └─┼─────┤ │
|
|
1644
|
+
2│ . │ . │ O . . │ O─┼─O . . . . . O O─┼─O │
|
|
1645
|
+
│ │ │ └───┤ ┌───┐ ┌───────────────┘ │
|
|
1646
|
+
3│ O │ . │ . . . O─┼─O . │ . │ O │ . . . . . │
|
|
1647
|
+
├─┼─┤ └───────────┐ ├───────┘ └─┼─┴───────────┐ │
|
|
1648
|
+
4│ O │ . . . . │ O─┼─O . . O . . . │ . . │
|
|
1649
|
+
│ └───────┐ │ └───┐ ┌───────────┐ ┌───┘ │
|
|
1650
|
+
5│ . . . │ . . │ . . │ . │ . . . │ . │ . O . │
|
|
1651
|
+
│ ┌───┘ │ ├───┘ │ └─────┼─┐ │
|
|
1652
|
+
6│ . . │ O . . │ . O─┼─O . O . │ . . O │ . │
|
|
1653
|
+
│ └─┼─────────┼───────┘ ┌─────┼─┐ │ ┌───┐ │ │
|
|
1654
|
+
7│ . O O . O─┼─O . . │ . O │ . │ O─┼─O │ O │ . │
|
|
1655
|
+
├─────┼─┐ ┌───┴───────────┘ │ └───┘ ├─┼─┤ │
|
|
1656
|
+
8│ . O │ . . │ . . . . . . │ . . . │ O │ . │
|
|
1657
|
+
│ │ ┌───┘ └───┐ │ │ │
|
|
1658
|
+
9│ . . │ O─┼─O . . . . . . O │ . O─┼─O │ O │
|
|
1659
|
+
│ ┌───┴───┘ ┌───────────┬───┐ ┌─┼─┴───────┘ └─┼─┤
|
|
1660
|
+
10│ . │ . O . │ . . O─┼─O │ . . │ O . . . O │
|
|
1661
|
+
│ └─────┼─┐ │ │ │ ┌───┘ ┌───────┐ │
|
|
1662
|
+
11│ O O O │ O─┼─O O O │ O─┼─O │ . . . │ . O─┼─O │
|
|
1663
|
+
├─┼─┬─┼─┐ ├───┘ ┌─┼─┬─┼─┤ └───┤ ┌───────┘ │ │
|
|
1664
|
+
12│ O │ O │ . │ . . │ O │ O │ . . │ . │ . . . . │ . │
|
|
1665
|
+
│ │ │ │ ┌───┘ │ └───┐ └───┘ │ │
|
|
1666
|
+
13│ . │ . │ O─┼─O │ . . │ . . │ . . O . . . │ . │
|
|
1667
|
+
│ │ └───┤ │ │ └─────────┼─┐ └───┤
|
|
1668
|
+
14│ O─┼─O O─┼─O │ . O─┼─O . . . O │ . . . . │
|
|
1669
|
+
└───┴───────┴───┴───────┴───────────────────┴───────────────┘
|
|
1670
|
+
Solutions found: 1
|
|
1671
|
+
status: OPTIMAL
|
|
1672
|
+
Time taken: 0.01 seconds
|
|
1673
|
+
```
|
|
1674
|
+
|
|
1675
|
+
**Solved puzzle**
|
|
1676
|
+
|
|
1677
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/stitches_solved.png" alt="Stitches solved" width="500">
|
|
1678
|
+
|
|
1679
|
+
---
|
|
1680
|
+
|
|
1681
|
+
## Battleships (Puzzle Type #29)
|
|
1682
|
+
|
|
1683
|
+
* [**Play online**](https://www.puzzle-battleships.com/)
|
|
1684
|
+
|
|
1685
|
+
* [**Solver Code**](https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/battleships)
|
|
1686
|
+
|
|
1687
|
+
<details>
|
|
1688
|
+
<summary><strong>Rules</strong></summary>
|
|
1689
|
+
|
|
1690
|
+
- You have to find the location of the battleships hidden in the grid. Some battleships may be partially revealed.
|
|
1691
|
+
- A battleship is a straight line of consecutive black cells.
|
|
1692
|
+
- The number of the battleships from each size is shown in the legend.
|
|
1693
|
+
- 2 battleships cannot touch each other (even diagonally)
|
|
1694
|
+
- The numbers outside the grid show the number of cells occupied by battleships on that row/column.
|
|
1695
|
+
|
|
1696
|
+
</details>
|
|
1697
|
+
|
|
1698
|
+
**Unsolved puzzle**
|
|
1699
|
+
|
|
1700
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/battleships_unsolved.png" alt="Battleships unsolved" width="500">
|
|
1701
|
+
|
|
1702
|
+
Code to utilize this package and solve the puzzle:
|
|
1703
|
+
|
|
1704
|
+
```python
|
|
1705
|
+
import numpy as np
|
|
1706
|
+
from puzzle_solver import battleships_solver as solver
|
|
1707
|
+
board = np.array([
|
|
1708
|
+
[' ', ' ', ' ', ' ', ' ', 'S', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '],
|
|
1709
|
+
[' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'S', ' ', ' ', ' ', ' '],
|
|
1710
|
+
[' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'O', ' ', ' '],
|
|
1711
|
+
[' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '],
|
|
1712
|
+
[' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '],
|
|
1713
|
+
['W', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '],
|
|
1714
|
+
[' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '],
|
|
1715
|
+
[' ', ' ', ' ', ' ', ' ', ' ', 'O', ' ', ' ', ' ', ' ', 'W', ' ', ' ', 'R'],
|
|
1716
|
+
[' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '],
|
|
1717
|
+
[' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '],
|
|
1718
|
+
[' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '],
|
|
1719
|
+
[' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'U', ' ', ' ', ' ', ' '],
|
|
1720
|
+
[' ', ' ', ' ', ' ', ' ', ' ', ' ', 'L', ' ', ' ', ' ', ' ', ' ', ' ', ' '],
|
|
1721
|
+
[' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '],
|
|
1722
|
+
[' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'S'],
|
|
1723
|
+
])
|
|
1724
|
+
top = np.array([2, 2, 4, 2, 1, 2, 1, 2, 4, 1, 3, 2, 5, 2, 2])
|
|
1725
|
+
side = np.array([1, 2, 1, 1, 0, 7, 0, 9, 2, 2, 5, 1, 3, 0, 1])
|
|
1726
|
+
ship_counts = {1: 5, 2: 4, 3: 3, 4: 2, 5: 1}
|
|
1727
|
+
binst = solver.Board(board=board, top=top, side=side, ship_counts=ship_counts)
|
|
1728
|
+
solutions = binst.solve_and_print()
|
|
1729
|
+
```
|
|
1730
|
+
|
|
1731
|
+
|
|
1732
|
+
**Script Output**
|
|
1733
|
+
|
|
1734
|
+
```python
|
|
1735
|
+
Solution found
|
|
1736
|
+
0 0 0 0 0 0 0 0 0 0 1 1 1 1 1
|
|
1737
|
+
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4
|
|
1738
|
+
┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┐
|
|
1739
|
+
0│ │ │ │ │ │▒▒▒│ │ │ │ │ │ │ │ │ │
|
|
1740
|
+
├───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┤
|
|
1741
|
+
1│ │ │ │ │ │ │ │ │ │ │▒▒▒│ │▒▒▒│ │ │
|
|
1742
|
+
├───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┤
|
|
1743
|
+
2│ │ │ │ │ │ │ │ │ │ │ │ │▒▒▒│ │ │
|
|
1744
|
+
├───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┤
|
|
1745
|
+
3│ │ │ │ │ │ │ │ │ │ │ │ │▒▒▒│ │ │
|
|
1746
|
+
├───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┤
|
|
1747
|
+
4│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
|
|
1748
|
+
├───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┤
|
|
1749
|
+
5│ │▒▒▒│▒▒▒│▒▒▒│▒▒▒│ │ │ │ │ │ │▒▒▒│▒▒▒│▒▒▒│ │
|
|
1750
|
+
├───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┤
|
|
1751
|
+
6│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
|
|
1752
|
+
├───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┤
|
|
1753
|
+
7│ │ │▒▒▒│ │ │▒▒▒│▒▒▒│▒▒▒│▒▒▒│▒▒▒│ │ │▒▒▒│▒▒▒│▒▒▒│
|
|
1754
|
+
├───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┤
|
|
1755
|
+
8│▒▒▒│ │▒▒▒│ │ │ │ │ │ │ │ │ │ │ │ │
|
|
1756
|
+
├───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┤
|
|
1757
|
+
9│ │ │ │ │ │ │ │ │▒▒▒│ │ │▒▒▒│ │ │ │
|
|
1758
|
+
├───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┤
|
|
1759
|
+
10│▒▒▒│▒▒▒│▒▒▒│▒▒▒│ │ │ │ │▒▒▒│ │ │ │ │ │ │
|
|
1760
|
+
├───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┤
|
|
1761
|
+
11│ │ │ │ │ │ │ │ │ │ │▒▒▒│ │ │ │ │
|
|
1762
|
+
├───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┤
|
|
1763
|
+
12│ │ │ │ │ │ │ │▒▒▒│▒▒▒│ │▒▒▒│ │ │ │ │
|
|
1764
|
+
├───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┤
|
|
1765
|
+
13│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
|
|
1766
|
+
├───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┤
|
|
1767
|
+
14│ │ │ │ │ │ │ │ │ │ │ │ │ │ │▒▒▒│
|
|
1768
|
+
└───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┘
|
|
1769
|
+
Solutions found: 1
|
|
1770
|
+
status: OPTIMAL
|
|
1771
|
+
Time taken: 0.09 seconds
|
|
1772
|
+
Solution found
|
|
1773
|
+
```
|
|
1774
|
+
|
|
1775
|
+
**Solved puzzle**
|
|
1776
|
+
|
|
1777
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/battleships_solved.png" alt="Battleships solved" width="500">
|
|
1778
|
+
|
|
1779
|
+
---
|
|
1780
|
+
|
|
1781
|
+
## Star Battle Shapeless (Puzzle Type #32)
|
|
1782
|
+
|
|
1783
|
+
* [**Play online**](https://www.puzzle-star-battle.com/?size=14)
|
|
1784
|
+
|
|
1785
|
+
* [**Solver Code**](https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/star_battle)
|
|
1786
|
+
|
|
1787
|
+
<details>
|
|
1788
|
+
<summary><strong>Rules</strong></summary>
|
|
1789
|
+
|
|
1790
|
+
You have to place stars on the grid according to the rules:
|
|
1791
|
+
- 2 stars cannot be adjacent horizontally, vertically or diagonally.
|
|
1792
|
+
- For 1★ puzzles, you have to place 1 star on each row and column.
|
|
1793
|
+
- For 2★ puzzles, the stars per row and column must be 2 etc.
|
|
1794
|
+
- Some places begin with a black square and cannot have stars placed on them.
|
|
1795
|
+
|
|
1796
|
+
</details>
|
|
1797
|
+
|
|
1798
|
+
**Unsolved puzzle**
|
|
1799
|
+
|
|
1800
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/star_battle_shapeless_unsolved.png" alt="Star Battle Shapeless unsolved" width="500">
|
|
1801
|
+
|
|
1802
|
+
Code to utilize this package and solve the puzzle:
|
|
1803
|
+
|
|
1804
|
+
The `star_count` parameter depenends on the puzzle type.
|
|
1805
|
+
|
|
1806
|
+
```python
|
|
1807
|
+
import numpy as np
|
|
1808
|
+
from puzzle_solver import star_battle_shapeless as solver
|
|
1809
|
+
board = np.array([
|
|
1810
|
+
[' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '],
|
|
1811
|
+
['B', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '],
|
|
1812
|
+
['B', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'B', ' '],
|
|
1813
|
+
['B', 'B', ' ', ' ', 'B', ' ', ' ', ' ', ' ', ' '],
|
|
1814
|
+
['B', 'B', ' ', ' ', 'B', ' ', ' ', ' ', ' ', ' '],
|
|
1815
|
+
[' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '],
|
|
1816
|
+
[' ', ' ', ' ', ' ', 'B', ' ', ' ', ' ', 'B', ' '],
|
|
1817
|
+
['B', ' ', ' ', ' ', ' ', ' ', ' ', 'B', 'B', ' '],
|
|
1818
|
+
['B', 'B', ' ', ' ', ' ', ' ', 'B', 'B', 'B', ' '],
|
|
1819
|
+
['B', ' ', ' ', ' ', 'B', ' ', ' ', ' ', ' ', ' '],
|
|
1820
|
+
])
|
|
1821
|
+
binst = solver.Board(board=board, star_count=2)
|
|
1822
|
+
solutions = binst.solve_and_print()
|
|
1823
|
+
```
|
|
1824
|
+
|
|
1825
|
+
|
|
1826
|
+
**Script Output**
|
|
1827
|
+
|
|
1828
|
+
```python
|
|
1829
|
+
Solution found
|
|
1830
|
+
0 0 0 0 0 0 0 0 0 0
|
|
1831
|
+
0 1 2 3 4 5 6 7 8 9
|
|
1832
|
+
┌───────────────────────────────────────┐
|
|
1833
|
+
0│ X . . . X . . . . . │
|
|
1834
|
+
├───┐ │
|
|
1835
|
+
1│ │ . . . . . X . X . │
|
|
1836
|
+
│ │ ┌───┐ │
|
|
1837
|
+
2│ │ . X . X . . . │ │ . │
|
|
1838
|
+
│ └───┐ ┌───┐ └───┘ │
|
|
1839
|
+
3│ │ . . │ │ . . X . X │
|
|
1840
|
+
│ │ │ │ │
|
|
1841
|
+
4│ │ X . │ │ X . . . . │
|
|
1842
|
+
├───────┘ └───┘ │
|
|
1843
|
+
5│ X . . . . . . . X . │
|
|
1844
|
+
│ ┌───┐ ┌───┐ │
|
|
1845
|
+
6│ . . . X │ │ . X . │ │ . │
|
|
1846
|
+
├───┐ └───┘ ┌───┘ │ │
|
|
1847
|
+
7│ │ X . . . . . │ │ X │
|
|
1848
|
+
│ └───┐ ┌───┘ │ │
|
|
1849
|
+
8│ │ . X . X │ │ . │
|
|
1850
|
+
│ ┌───┘ ┌───┐ └───────────┘ │
|
|
1851
|
+
9│ │ X . . │ │ . . X . . │
|
|
1852
|
+
└───┴───────────┴───┴───────────────────┘
|
|
1853
|
+
Solutions found: 1
|
|
1854
|
+
status: OPTIMAL
|
|
1855
|
+
Time taken: 0.02 seconds
|
|
1856
|
+
```
|
|
1857
|
+
|
|
1858
|
+
**Solved puzzle**
|
|
1859
|
+
|
|
1860
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/star_battle_shapeless_solved.png" alt="Star Battle Shapeless solved" width="500">
|
|
1861
|
+
|
|
1862
|
+
---
|
|
1863
|
+
|
|
1864
|
+
## Lits (Puzzle Type #33)
|
|
1865
|
+
|
|
1866
|
+
* [**Play online**](https://www.puzzle-lits.com/)
|
|
1867
|
+
|
|
1868
|
+
* [**Solver Code**](https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/lits)
|
|
1869
|
+
|
|
1870
|
+
<details>
|
|
1871
|
+
<summary><strong>Rules</strong></summary>
|
|
1872
|
+
|
|
1873
|
+
You have to place one tetromino in each region in such a way that:
|
|
1874
|
+
- 2 tetrominoes of matching types cannot touch each other horizontally or vertically. Rotations and reflections count as matching.
|
|
1875
|
+
- The shaded cells should form a single connected area.
|
|
1876
|
+
- 2x2 shaded areas are not allowed.
|
|
1877
|
+
|
|
1878
|
+
* Tetromino is a shape made of 4 connected cells. There are 5 types of tetrominoes, which are usually named L, I, T, S and O, based on their shape. The O tetromino is not used in this puzzle because it is a 2x2 shape, which is not allowed.
|
|
1879
|
+
|
|
1880
|
+
</details>
|
|
1881
|
+
|
|
1882
|
+
Note: The solver is capable of solving variations where the puzzle pieces the made up of more than 4 cells (e.g., pentominoes for 5 with `polyomino_degrees=5`, or hexominoes for 6 with `polyomino_degrees=6`, etc.). By default the degree is set to 4 thus only tetrominoes are used.
|
|
1883
|
+
|
|
1884
|
+
**Unsolved puzzle**
|
|
1885
|
+
|
|
1886
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/lits_unsolved.png" alt="Lits unsolved" width="500">
|
|
1887
|
+
|
|
1888
|
+
Code to utilize this package and solve the puzzle:
|
|
1889
|
+
|
|
1890
|
+
```python
|
|
1891
|
+
import numpy as np
|
|
1892
|
+
from puzzle_solver import lits_solver as solver
|
|
1893
|
+
board = np.array([
|
|
1894
|
+
['00', '00', '00', '01', '01', '02', '02', '02', '03', '03', '03', '04', '04', '05', '06', '07', '07', '08', '08', '09'],
|
|
1895
|
+
['00', '00', '00', '00', '01', '02', '03', '03', '03', '10', '04', '04', '05', '05', '06', '07', '08', '08', '09', '09'],
|
|
1896
|
+
['11', '11', '11', '01', '01', '02', '02', '03', '10', '10', '04', '04', '05', '06', '06', '07', '07', '07', '09', '12'],
|
|
1897
|
+
['11', '13', '13', '13', '01', '02', '03', '03', '03', '10', '04', '04', '06', '06', '06', '07', '12', '09', '09', '12'],
|
|
1898
|
+
['11', '11', '11', '13', '14', '14', '03', '15', '15', '10', '04', '04', '06', '16', '16', '12', '12', '09', '12', '12'],
|
|
1899
|
+
['17', '13', '13', '13', '14', '14', '03', '03', '15', '15', '04', '04', '16', '16', '16', '12', '12', '12', '12', '18'],
|
|
1900
|
+
['17', '13', '19', '13', '20', '14', '03', '03', '15', '04', '04', '16', '16', '21', '21', '22', '23', '23', '23', '18'],
|
|
1901
|
+
['17', '17', '19', '19', '20', '20', '03', '03', '24', '24', '24', '25', '25', '25', '21', '22', '23', '23', '18', '18'],
|
|
1902
|
+
['17', '26', '19', '19', '20', '20', '20', '24', '24', '20', '20', '25', '25', '21', '21', '22', '22', '23', '23', '18'],
|
|
1903
|
+
['26', '26', '26', '19', '19', '20', '20', '20', '20', '20', '25', '25', '21', '21', '21', '21', '21', '23', '27', '18'],
|
|
1904
|
+
['28', '28', '28', '29', '29', '29', '29', '20', '20', '30', '30', '25', '31', '32', '32', '32', '21', '27', '27', '27'],
|
|
1905
|
+
['28', '33', '28', '28', '28', '28', '29', '34', '34', '35', '30', '30', '31', '31', '31', '32', '32', '36', '36', '27'],
|
|
1906
|
+
['28', '33', '33', '28', '28', '29', '29', '34', '34', '35', '35', '30', '31', '31', '31', '32', '36', '36', '27', '27'],
|
|
1907
|
+
['28', '33', '37', '37', '28', '29', '34', '34', '35', '35', '38', '38', '39', '39', '40', '40', '40', '40', '27', '41'],
|
|
1908
|
+
['28', '37', '37', '37', '42', '34', '34', '34', '43', '38', '38', '38', '39', '39', '44', '44', '40', '40', '27', '41'],
|
|
1909
|
+
['37', '37', '42', '42', '42', '34', '34', '43', '43', '43', '38', '39', '39', '39', '44', '44', '27', '27', '27', '41'],
|
|
1910
|
+
['45', '45', '45', '42', '46', '34', '34', '34', '34', '38', '38', '47', '47', '47', '44', '44', '44', '27', '27', '41'],
|
|
1911
|
+
['48', '45', '45', '46', '46', '46', '46', '34', '49', '49', '49', '47', '44', '44', '44', '27', '44', '50', '27', '27'],
|
|
1912
|
+
['48', '48', '45', '46', '46', '51', '46', '52', '52', '49', '49', '53', '44', '53', '44', '27', '50', '50', '50', '27'],
|
|
1913
|
+
['48', '51', '51', '51', '51', '51', '52', '52', '52', '49', '53', '53', '53', '53', '44', '27', '27', '27', '27', '27']
|
|
1914
|
+
])
|
|
1915
|
+
binst = solver.Board(board)
|
|
1916
|
+
solutions = binst.solve_then_constrain() # solve_then_constrain NOT solve_and_print (to use #1 instead of #2 in https://github.com/google/or-tools/discussions/3347, its faster in this case)
|
|
1917
|
+
```
|
|
1918
|
+
|
|
1919
|
+
**Script Output**
|
|
1920
|
+
|
|
1921
|
+
```python
|
|
1922
|
+
Solution found
|
|
1923
|
+
0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1
|
|
1924
|
+
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9
|
|
1925
|
+
┌───────────┬───────┬───────────┬───────────┬───────┬───┬───┬───────┬───────┬───┐
|
|
1926
|
+
0│▒▒▒ ▒▒▒ ▒▒▒│ │▒▒▒ ▒▒▒ ▒▒▒│ │ │▒▒▒│ │▒▒▒ │▒▒▒ ▒▒▒│ │
|
|
1927
|
+
│ └───┐ │ ┌───────┘ ┌───┬───┘ ┌───┘ │ │ ┌───┘ ┌───┘ │
|
|
1928
|
+
1│ ▒▒▒ │▒▒▒│▒▒▒│ │▒▒▒│ │▒▒▒ ▒▒▒│ │▒▒▒│▒▒▒ ▒▒▒│ │
|
|
1929
|
+
├───────────┬───┘ │ └───┐ ┌───┘ │ │ ┌───┘ │ └───────┤ ┌───┤
|
|
1930
|
+
2│▒▒▒ ▒▒▒ ▒▒▒│▒▒▒ ▒▒▒│ │▒▒▒│▒▒▒ ▒▒▒│ │▒▒▒│ │▒▒▒ │▒▒▒│ │
|
|
1931
|
+
│ ┌───────┴───┐ │ ┌───┘ └───┐ │ ├───┘ │ ┌───┬───┘ │ │
|
|
1932
|
+
3│▒▒▒│ │▒▒▒│ │▒▒▒ ▒▒▒ │▒▒▒│▒▒▒ │▒▒▒ ▒▒▒ ▒▒▒│▒▒▒│ │▒▒▒ ▒▒▒│ │
|
|
1933
|
+
│ └───────┐ ├───┴───┤ ┌───────┤ │ │ ┌───────┼───┘ │ ┌───┘ │
|
|
1934
|
+
4│ │▒▒▒│▒▒▒ ▒▒▒│▒▒▒│ ▒▒▒│ │▒▒▒ │▒▒▒│ │ │▒▒▒│ │
|
|
1935
|
+
├───┬───────┘ │ │ └───┐ └───┤ ├───┘ │ └───┘ ┌───┤
|
|
1936
|
+
5│▒▒▒│ ▒▒▒ ▒▒▒│ ▒▒▒│ │▒▒▒ ▒▒▒│▒▒▒ │▒▒▒ ▒▒▒ │▒▒▒ ▒▒▒ ▒▒▒ ▒▒▒│ │
|
|
1937
|
+
│ │ ┌───┐ ├───┐ │ │ ┌───┘ ┌───┘ ┌───────┼───┬───────────┤ │
|
|
1938
|
+
6│▒▒▒│ │ │▒▒▒│ │▒▒▒│ │▒▒▒│ ▒▒▒│▒▒▒ ▒▒▒│ │▒▒▒│ │▒▒▒│
|
|
1939
|
+
│ └───┤ └───┤ └───┤ ├───┴───────┼───────┴───┐ │ │ ┌───┘ │
|
|
1940
|
+
7│▒▒▒ ▒▒▒│ ▒▒▒│ ▒▒▒│ │▒▒▒ ▒▒▒ │▒▒▒ │ │▒▒▒│ ▒▒▒│ ▒▒▒│
|
|
1941
|
+
│ ┌───┤ │ └───┬───┘ ┌───────┤ ┌───┘ │ └───┐ └───┐ │
|
|
1942
|
+
8│ │▒▒▒│ ▒▒▒│ ▒▒▒ ▒▒▒│▒▒▒ ▒▒▒│ │▒▒▒ │▒▒▒ ▒▒▒│▒▒▒ ▒▒▒│▒▒▒ ▒▒▒│▒▒▒│
|
|
1943
|
+
├───┘ └───┐ └───┐ └───────┘ ┌───┘ ┌───┘ └───────┤ ┌───┤ │
|
|
1944
|
+
9│▒▒▒ ▒▒▒ ▒▒▒│▒▒▒ ▒▒▒│▒▒▒ │▒▒▒ ▒▒▒│▒▒▒ ▒▒▒ │▒▒▒│ │▒▒▒│
|
|
1945
|
+
├───────────┼───────┴───────┐ ┌───┴───┐ ├───┬───────────┐ ├───┘ └───┤
|
|
1946
|
+
10│ │ ▒▒▒ ▒▒▒│ │ ▒▒▒│ │ │▒▒▒ ▒▒▒ ▒▒▒│ │ │
|
|
1947
|
+
│ ┌───┐ └───────────┐ ├───────┼───┐ └───┤ └───────┐ └───┼───────┐ │
|
|
1948
|
+
11│ │▒▒▒│ ▒▒▒ ▒▒▒ │▒▒▒│ │▒▒▒│▒▒▒ ▒▒▒│ ▒▒▒ │▒▒▒ │▒▒▒ ▒▒▒│ │
|
|
1949
|
+
│ │ └───┐ ┌───┘ │ │ └───┐ │ │ ┌───┘ ┌───┘ │
|
|
1950
|
+
12│ │▒▒▒ ▒▒▒│ ▒▒▒│ ▒▒▒│ │▒▒▒ │▒▒▒│▒▒▒ ▒▒▒ ▒▒▒│ │▒▒▒ ▒▒▒│ │
|
|
1951
|
+
│ │ ┌───┴───┐ │ ┌───┘ ┌───┘ ┌───┴───┼───────┬───┴───┴───────┤ ┌───┤
|
|
1952
|
+
13│ │▒▒▒│ │▒▒▒│ │▒▒▒ │▒▒▒ ▒▒▒│▒▒▒ │▒▒▒ │▒▒▒ ▒▒▒ ▒▒▒ │ │▒▒▒│
|
|
1953
|
+
│ ├───┘ ├───┼───┘ ├───┬───┘ │ ├───────┐ │ │ │
|
|
1954
|
+
14│ │▒▒▒ ▒▒▒ │▒▒▒│ ▒▒▒ │▒▒▒│ ▒▒▒ │▒▒▒ ▒▒▒│ │▒▒▒ │ │▒▒▒│
|
|
1955
|
+
├───┘ ┌───────┘ │ ┌───┘ └───┐ ┌───┘ │ ├───────┘ │ │
|
|
1956
|
+
15│▒▒▒ ▒▒▒│ ▒▒▒ ▒▒▒│ ▒▒▒│▒▒▒ ▒▒▒ ▒▒▒│▒▒▒│ ▒▒▒│ │▒▒▒ ▒▒▒ │▒▒▒│
|
|
1957
|
+
├───────┴───┐ ┌───┤ └───────┬───┘ ├───────────┤ └───┐ │ │
|
|
1958
|
+
16│ ▒▒▒ ▒▒▒│▒▒▒│ │ ▒▒▒ │ ▒▒▒│▒▒▒ ▒▒▒ ▒▒▒│▒▒▒ │▒▒▒ ▒▒▒│▒▒▒│
|
|
1959
|
+
├───┐ ├───┘ └───────┐ ┌───┴───────┤ ┌───────┘ ┌───┐ ├───┐ └───┤
|
|
1960
|
+
17│▒▒▒│ ▒▒▒│ ▒▒▒ ▒▒▒ ▒▒▒│ │▒▒▒ ▒▒▒ │▒▒▒│ ▒▒▒│ │ │▒▒▒│ │
|
|
1961
|
+
│ └───┐ │ ┌───┐ ├───┴───┐ ├───┤ ┌───┐ │ ├───┘ └───┐ │
|
|
1962
|
+
18│▒▒▒ ▒▒▒│▒▒▒│ ▒▒▒│ │ │▒▒▒ │▒▒▒ │▒▒▒│ │ │▒▒▒│ │▒▒▒ ▒▒▒ ▒▒▒│ │
|
|
1963
|
+
│ ┌───┴───┴───────┘ ├───┘ │ ┌───┘ └───┘ │ │ └───────────┘ │
|
|
1964
|
+
19│▒▒▒│ ▒▒▒ ▒▒▒ ▒▒▒ ▒▒▒│▒▒▒ ▒▒▒ ▒▒▒│▒▒▒│▒▒▒ ▒▒▒ ▒▒▒ │▒▒▒│ │
|
|
1965
|
+
└───┴───────────────────┴───────────┴───┴───────────────┴───┴───────────────────┘
|
|
1966
|
+
Solutions found: 1
|
|
1967
|
+
status: OPTIMAL
|
|
1968
|
+
Time taken: 0.09 seconds
|
|
1969
|
+
```
|
|
1970
|
+
|
|
1971
|
+
**Solved puzzle**
|
|
1972
|
+
|
|
1973
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/lits_solved.png" alt="Lits solved" width="500">
|
|
1974
|
+
|
|
1975
|
+
---
|
|
1976
|
+
|
|
1977
|
+
## Galaxies (Puzzle Type #35)
|
|
1978
|
+
|
|
1979
|
+
Also known as Tentai Show, Tentaisho, Galaxies, Spiral Galaxies, or Sym-a-Pix.
|
|
1980
|
+
|
|
1981
|
+
* [**Play online**](https://www.chiark.greenend.org.uk/~sgtatham/puzzles/js/galaxies.html)
|
|
1982
|
+
|
|
1983
|
+
* [**Instructions**](https://www.chiark.greenend.org.uk/~sgtatham/puzzles/doc/galaxies.html#galaxies)
|
|
1984
|
+
|
|
1985
|
+
* [**Solver Code**](https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/galaxies)
|
|
1986
|
+
|
|
1987
|
+
<details>
|
|
1988
|
+
<summary><strong>Rules</strong></summary>
|
|
1989
|
+
|
|
1990
|
+
You have a rectangular grid containing a number of dots. Your aim is to partition the rectangle into connected regions of squares, in such a way that every region is 180° rotationally symmetric, and contains exactly one dot which is located at its centre of symmetry.
|
|
1991
|
+
|
|
1992
|
+
To enter your solution, you draw lines along the grid edges to mark the boundaries of the regions. The puzzle is complete when the marked lines on the grid are precisely those that separate two squares belonging to different regions.
|
|
1993
|
+
|
|
1994
|
+
</details>
|
|
1995
|
+
|
|
1996
|
+
**Unsolved puzzle**
|
|
1997
|
+
|
|
1998
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/galaxies_unsolved.png" alt="Galaxies unsolved" width="500">
|
|
1999
|
+
|
|
2000
|
+
Code to utilize this package and solve the puzzle:
|
|
2001
|
+
|
|
2002
|
+
Note: The number are arbitrary and simply number each galaxy as an integer.
|
|
2003
|
+
|
|
2004
|
+
```python
|
|
2005
|
+
import numpy as np
|
|
2006
|
+
from puzzle_solver import galaxies_solver as solver
|
|
2007
|
+
galaxies = np.array([
|
|
2008
|
+
[' ', ' ', '00', ' ', ' ', '01', '01', '02', '02', '03', '03', ' ', '04', '04', ' '],
|
|
2009
|
+
['05', '05', ' ', ' ', '06', '01', '01', '02', '02', ' ', ' ', ' ', '07', ' ', ' '],
|
|
2010
|
+
['08', ' ', ' ', ' ', '06', ' ', '09', '09', ' ', ' ', '10', ' ', ' ', ' ', ' '],
|
|
2011
|
+
[' ', ' ', ' ', ' ', ' ', ' ', '11', '11', '12', ' ', ' ', ' ', ' ', '13', '13'],
|
|
2012
|
+
['14', ' ', ' ', ' ', '15', ' ', '11', '11', ' ', ' ', ' ', ' ', '16', ' ', ' '],
|
|
2013
|
+
[' ', '17', ' ', ' ', '15', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '16', ' ', '18'],
|
|
2014
|
+
[' ', '17', '19', ' ', ' ', ' ', ' ', ' ', ' ', '20', ' ', ' ', ' ', '21', '18'],
|
|
2015
|
+
[' ', '22', ' ', ' ', '23', ' ', ' ', ' ', ' ', '20', ' ', '24', '24', '21', '25'],
|
|
2016
|
+
['26', '27', '27', '28', '28', '29', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '30', '30'],
|
|
2017
|
+
[' ', '27', '27', '28', '28', '31', '31', ' ', ' ', ' ', ' ', '32', ' ', '30', '30'],
|
|
2018
|
+
[' ', ' ', ' ', '33', '33', '31', '31', '34', ' ', ' ', '35', ' ', ' ', ' ', ' '],
|
|
2019
|
+
['36', ' ', ' ', '33', '33', ' ', ' ', '34', ' ', ' ', ' ', ' ', ' ', '37', ' '],
|
|
2020
|
+
[' ', ' ', '38', '38', ' ', '39', ' ', '40', '40', '41', '41', '42', ' ', '37', ' '],
|
|
2021
|
+
['43', '44', '38', '38', '45', '45', '46', '40', '40', '41', '41', '42', ' ', ' ', ' '],
|
|
2022
|
+
['43', ' ', ' ', ' ', ' ', ' ', ' ', '47', ' ', ' ', ' ', ' ', '48', '48', ' ']
|
|
2023
|
+
])
|
|
2024
|
+
binst = solver.Board(galaxies=galaxies)
|
|
2025
|
+
solutions = binst.solve_and_print()
|
|
2026
|
+
```
|
|
2027
|
+
**Script Output**
|
|
2028
|
+
|
|
2029
|
+
As the instructions say, the solution to this puzzle is not garunteed to be unique.
|
|
2030
|
+
|
|
2031
|
+
```python
|
|
2032
|
+
Solution found
|
|
2033
|
+
0 0 0 0 0 0 0 0 0 0 1 1 1 1 1
|
|
2034
|
+
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4
|
|
2035
|
+
┌───────────────────┬───────┬───────┬───────┬───────────────┐
|
|
2036
|
+
0│ . │ . . │ . . │ . . │ . . │
|
|
2037
|
+
├───────┬───┬───────┤ │ ├───────┼───────────┬───┤
|
|
2038
|
+
1│ . . │ │ . │ . . │ . . │ │ . │ │
|
|
2039
|
+
├───┬───┘ └───┐ └───┬───┴───┬───┘ └───────┬───┘ │
|
|
2040
|
+
2│ . │ │ . │ . . │ . │ │
|
|
2041
|
+
├───┤ └───────┼───────┼───┬───┐ ┌───┤ │
|
|
2042
|
+
3│ │ │ . . │ . │ │ │ │ . . │
|
|
2043
|
+
│ │ │ ├───┘ └───────┤ │ │
|
|
2044
|
+
4│ . │ . │ . . │ │ . │ │
|
|
2045
|
+
│ ├───────┐ └───────┤ │ │ ┌───┤
|
|
2046
|
+
5│ │ . │ . │ │ . │ │ . │
|
|
2047
|
+
├───┘ ┌───┤ │ ┌───┤ ├───┤ │
|
|
2048
|
+
6│ . │ . │ │ . │ │ │ . │ . │
|
|
2049
|
+
├───┬───┼───┴───┬───┐ │ │ └───┤ ├───┤
|
|
2050
|
+
7│ │ . │ │ . │ │ . │ . . │ . │ . │
|
|
2051
|
+
│ ├───┘ ┌───┴───┼───┐ ┌───┘ ├───┐ ├───┴───┤
|
|
2052
|
+
8│ . │ . . │ . . │ . │ │ │ │ │ . . │
|
|
2053
|
+
│ │ │ ├───┴───┤ │ ├───┤ │
|
|
2054
|
+
9│ │ . . │ . . │ . . │ │ . │ │ . . │
|
|
2055
|
+
├───┘ ┌───┴───────┤ ├───────┐ ┌───┤ │ └───────┤
|
|
2056
|
+
10│ │ . . │ . . │ . │ │ . │ │ │
|
|
2057
|
+
├───┬───┴───┐ └───┬───┘ ┌───┴───┴───┴───┤ │
|
|
2058
|
+
11│ . │ │ . . │ . │ │ . │
|
|
2059
|
+
├───┴───┐ └───┬───┬───┼───┬───┴───┐ ┌───┤ │
|
|
2060
|
+
12│ │ . . │ │ . │ │ . . │ . . │ . │ . │
|
|
2061
|
+
├───┐ │ │ └───┤ │ │ │ │ │
|
|
2062
|
+
13│ . │ . │ . . │ . . │ . │ . . │ . . │ . │ │
|
|
2063
|
+
│ │ └───┐ └───┐ │ ├───┬───┘ └───┼───────┐ │
|
|
2064
|
+
14│ . │ │ │ │ │ . │ │ . . │ │
|
|
2065
|
+
└───┴───────┴───────┴───┴───┴───┴───────────────┴───────┴───┘
|
|
2066
|
+
Solutions found: 1
|
|
2067
|
+
status: OPTIMAL
|
|
2068
|
+
Time taken: 0.06 seconds
|
|
2069
|
+
```
|
|
2070
|
+
|
|
2071
|
+
**Solved puzzle**
|
|
2072
|
+
|
|
2073
|
+
Applying the solution to the puzzle visually:
|
|
2074
|
+
|
|
2075
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/galaxies_solved.png" alt="Galaxies solved" width="500">
|
|
2076
|
+
|
|
2077
|
+
---
|
|
2078
|
+
|
|
2079
|
+
## Slitherlink (Puzzle Type #39)
|
|
2080
|
+
|
|
2081
|
+
Also known as Fences, Loop the Loop, or Loopy.
|
|
2082
|
+
|
|
2083
|
+
* [**Play online 1**](https://www.chiark.greenend.org.uk/~sgtatham/puzzles/js/loopy.html)
|
|
2084
|
+
|
|
2085
|
+
* [**Play online 2**](https://www.puzzle-loop.com)
|
|
2086
|
+
|
|
2087
|
+
* [**Instructions**](https://www.chiark.greenend.org.uk/~sgtatham/puzzles/doc/loopy.html#loopy)
|
|
2088
|
+
|
|
2089
|
+
* [**Solver Code**](https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/slitherlink)
|
|
2090
|
+
|
|
2091
|
+
<details>
|
|
2092
|
+
<summary><strong>Rules</strong></summary>
|
|
2093
|
+
|
|
2094
|
+
You have to draw lines between the dots to form a single loop without crossings or branches. The numbers indicate how many lines surround it.
|
|
2095
|
+
|
|
2096
|
+
A line forming a single loop without crossings or branches means that every corner has either 2 or 0 lines touching it.
|
|
2097
|
+
|
|
2098
|
+
</details>
|
|
2099
|
+
|
|
2100
|
+
**Unsolved puzzle**
|
|
2101
|
+
|
|
2102
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/slitherlink_unsolved.png" alt="Slitherlink unsolved" width="500">
|
|
2103
|
+
|
|
2104
|
+
Code to utilize this package and solve the puzzle:
|
|
2105
|
+
|
|
2106
|
+
```python
|
|
2107
|
+
import numpy as np
|
|
2108
|
+
from puzzle_solver import slitherlink_solver as solver
|
|
2109
|
+
board = np.array([
|
|
2110
|
+
['3', ' ', ' ', '2', ' ', ' ', ' ', ' ', ' ', '3', ' ', ' ', ' ', ' ', ' ', '3', ' ', ' ', '1', ' '],
|
|
2111
|
+
[' ', ' ', '3', ' ', '3', ' ', ' ', ' ', '3', ' ', '2', '2', ' ', '2', ' ', '2', '2', ' ', '2', '3'],
|
|
2112
|
+
['2', '2', ' ', ' ', ' ', '2', '1', ' ', '1', '1', ' ', ' ', '3', '1', ' ', '2', ' ', ' ', ' ', '2'],
|
|
2113
|
+
[' ', ' ', '2', ' ', ' ', '2', '2', ' ', ' ', ' ', '3', ' ', ' ', ' ', ' ', ' ', '2', '2', '3', ' '],
|
|
2114
|
+
['1', '2', '1', ' ', ' ', ' ', '2', '1', ' ', '3', '2', ' ', '3', '2', '2', '3', ' ', '3', '2', '2'],
|
|
2115
|
+
[' ', '3', '2', '2', '1', '2', ' ', '3', ' ', ' ', ' ', ' ', '2', '2', '3', ' ', '1', '1', ' ', '2'],
|
|
2116
|
+
['1', ' ', ' ', ' ', ' ', ' ', '2', ' ', ' ', '2', ' ', '1', '3', ' ', ' ', ' ', ' ', '2', '2', '2'],
|
|
2117
|
+
[' ', '3', ' ', '2', '0', '1', '2', '1', ' ', '1', '3', ' ', '2', ' ', ' ', '2', ' ', '2', '1', ' '],
|
|
2118
|
+
['2', ' ', ' ', ' ', '2', ' ', '3', ' ', ' ', ' ', ' ', '2', ' ', ' ', '1', '2', ' ', ' ', '1', '3'],
|
|
2119
|
+
[' ', ' ', '1', ' ', ' ', ' ', ' ', '2', '0', ' ', '1', ' ', '2', ' ', '0', ' ', '2', ' ', '3', '2'],
|
|
2120
|
+
[' ', '3', ' ', '3', ' ', '1', '3', ' ', '3', ' ', '2', ' ', ' ', '2', '2', '2', '3', ' ', ' ', ' '],
|
|
2121
|
+
['3', ' ', ' ', ' ', ' ', ' ', ' ', '0', '2', '1', ' ', ' ', '2', ' ', ' ', '1', ' ', '0', '2', ' '],
|
|
2122
|
+
[' ', ' ', ' ', ' ', ' ', ' ', '3', ' ', '3', '2', '3', ' ', ' ', '2', ' ', '1', ' ', ' ', ' ', ' '],
|
|
2123
|
+
['2', '2', ' ', '3', '0', ' ', ' ', '3', ' ', ' ', '2', ' ', ' ', ' ', ' ', '2', '2', ' ', '3', ' '],
|
|
2124
|
+
[' ', '2', '0', ' ', ' ', '3', ' ', '1', ' ', ' ', '2', ' ', '2', '2', ' ', ' ', ' ', '2', ' ', '2'],
|
|
2125
|
+
[' ', ' ', '1', '3', '1', ' ', ' ', ' ', ' ', ' ', '2', ' ', '2', '1', ' ', '1', '2', '2', ' ', ' '],
|
|
2126
|
+
['2', ' ', '2', '2', ' ', '1', '3', ' ', '2', ' ', '3', '1', '2', ' ', '3', '2', ' ', '1', '1', ' '],
|
|
2127
|
+
[' ', ' ', '2', ' ', '1', ' ', ' ', ' ', '2', ' ', ' ', ' ', '2', ' ', '1', '0', ' ', ' ', ' ', '3'],
|
|
2128
|
+
[' ', '2', ' ', ' ', '2', ' ', '2', '3', '2', ' ', '2', '2', ' ', '3', '2', '2', '3', '3', '1', ' '],
|
|
2129
|
+
['0', '0', ' ', '3', '2', ' ', ' ', ' ', ' ', ' ', '2', '1', '2', '1', ' ', ' ', ' ', '2', '1', ' '],
|
|
2130
|
+
])
|
|
2131
|
+
binst = solver.Board(board=board)
|
|
2132
|
+
solutions = binst.solve_and_print()
|
|
2133
|
+
```
|
|
2134
|
+
**Script Output**
|
|
2135
|
+
|
|
2136
|
+
```python
|
|
2137
|
+
Solution found
|
|
2138
|
+
0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1
|
|
2139
|
+
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9
|
|
2140
|
+
┌───┐ ┌───────┐ ┌───────────────────┐ ┌───────┐ ┌───┐ ┌───────────┐
|
|
2141
|
+
0│ 3 │ · │ · 2 │ · │ · · · · 3 │ · · │ · · │ · │ 3 │ · │ · 1 · │
|
|
2142
|
+
│ │ └───┐ │ │ ┌───────┐ ┌───┘ ┌───┘ ┌───┘ │ │ └───┐ ┌───┘
|
|
2143
|
+
1│ · │ · 3 │ · │ 3 │ · │ · · │ 3 │ · 2 │ 2 · │ 2 · │ 2 │ 2 · │ 2 │ 3
|
|
2144
|
+
│ │ ┌───┘ └───┘ │ └───┘ ┌───┘ ┌───┘ │ └───────┘ └───┐
|
|
2145
|
+
2│ 2 │ 2 │ · · · 2 │ 1 · 1 1 │ · · │ 3 1 · │ 2 · · · 2 │
|
|
2146
|
+
│ │ │ ┌───────────┘ ┌───┐ └───┐ └───────┐ └───────┐ ┌───┐ │
|
|
2147
|
+
3│ · │ · │ 2 │ · · 2 2 │ · │ · · 3 │ · · · │ · · 2 │ 2 │ 3 │ · │
|
|
2148
|
+
│ └───┘ └───────────────┘ └───┐ ┌───┘ ┌───┐ │ ┌───┐ │ │ │ │
|
|
2149
|
+
4│ 1 2 1 · · · 2 1 · │ 3 │ 2 · │ 3 │ 2 │ 2 │ 3 │ · │ 3 │ 2 │ 2 │
|
|
2150
|
+
│ ┌───────────────────────────┐ └───┘ ┌───┘ │ │ │ │ └───┘ │ │
|
|
2151
|
+
5│ · │ 3 2 2 1 2 · 3 │ · · · │ · 2 │ 2 │ 3 │ · │ 1 1 · │ 2 │
|
|
2152
|
+
│ └───────────┐ ┌───────────┘ ┌───────┘ ┌───┘ └───┘ │ ┌───┘ │
|
|
2153
|
+
6│ 1 · · · │ · │ · 2 · · │ 2 · 1 │ 3 · · · │ · 2 │ 2 2 │
|
|
2154
|
+
│ ┌───────────┘ └───────────────┘ ┌───┐ └───────────┐ └───────┘ ┌───┘
|
|
2155
|
+
7│ · │ 3 · 2 0 1 2 1 · 1 │ 3 │ · 2 · · │ 2 · 2 1 │ ·
|
|
2156
|
+
│ └───┐ ┌───┐ ┌───┐ ┌───┐ │ └───────────┐ └───┐ ┌───┐ └───┐
|
|
2157
|
+
8│ 2 · │ · │ · │ 2 · │ 3 │ · │ · │ · │ · 2 · · │ 1 2 │ · │ · │ 1 3 │
|
|
2158
|
+
└───┐ └───┘ └───┐ │ └───┘ └───┘ ┌───┐ ┌───┘ └───┘ │ ┌───┘
|
|
2159
|
+
9 · │ · 1 · · │ · │ · 2 0 · 1 │ · │ 2 │ · 0 · 2 · │ 3 │ 2
|
|
2160
|
+
└───┐ ┌───────┘ │ ┌───┐ ┌───┐ │ │ │ ┌───────┐ └───┘
|
|
2161
|
+
10 · 3 │ · │ 3 · 1 │ 3 │ · │ 3 │ · │ 2 │ · │ · │ 2 2 │ 2 3 │ · · ·
|
|
2162
|
+
┌───────┘ └───────┐ └───┘ └───┘ │ │ │ └───────┘ ┌───┘ ┌───┐
|
|
2163
|
+
11│ 3 · · · · │ · · 0 2 1 │ · │ · │ 2 · · 1 │ · 0 2 │ · │
|
|
2164
|
+
└───┐ ┌───────┐ │ ┌───┐ ┌───┐ │ │ └───┐ ┌───┐ └───┐ ┌───┘ │
|
|
2165
|
+
12 · │ · │ · · │ · │ · │ 3 │ · │ 3 │ 2 │ 3 │ · · │ 2 │ · │ 1 · │ · │ · · │
|
|
2166
|
+
┌───┘ │ ┌───┘ └───┘ │ │ │ └───┘ ┌───┘ │ │ ┌───┘ └───┐ │
|
|
2167
|
+
13│ 2 2 │ · │ 3 0 · · │ 3 │ · │ · 2 · │ · · │ · │ 2 │ 2 · 3 │ · │
|
|
2168
|
+
│ ┌───┘ └───┐ ┌───┐ └───┘ └───────────┘ ┌───┘ │ │ ┌───────┘ │
|
|
2169
|
+
14│ · │ 2 0 · │ · │ 3 │ · 1 · · 2 · 2 │ 2 · │ · │ · │ 2 · 2 │
|
|
2170
|
+
│ │ ┌───┘ │ │ ┌───────────────────┘ └───┘ │ ┌───────┘
|
|
2171
|
+
15│ · │ · 1 │ 3 1 │ · │ · · │ · · 2 · 2 1 · 1 2 │ 2 │ · ·
|
|
2172
|
+
│ └───┐ └───┐ │ └───┐ │ ┌───────────────────┐ ┌───┘ └───────┐
|
|
2173
|
+
16│ 2 · │ 2 2 │ · │ 1 3 │ · │ 2 · │ 3 1 2 · 3 │ 2 │ · 1 1 · │
|
|
2174
|
+
└───┐ └───┐ └───┘ ┌───┘ └───┐ └───┐ ┌───────────┘ └───────┐ ┌───┘
|
|
2175
|
+
17 · │ · 2 │ · 1 · │ · · 2 │ · · │ · │ 2 · 1 0 · · │ · │ 3
|
|
2176
|
+
└───┐ └───┐ ┌───┘ ┌───┐ │ │ │ ┌───┐ ┌───┐ │ └───┐
|
|
2177
|
+
18 · 2 │ · · │ 2 │ · 2 │ 3 │ 2 │ · 2 │ 2 │ · │ 3 │ 2 2 │ 3 │ 3 │ 1 · │
|
|
2178
|
+
└───┐ │ │ ┌───┘ │ └───────┘ └───┘ └───────┘ └───┘ │
|
|
2179
|
+
19 0 0 · │ 3 │ 2 │ · │ · · │ · · 2 1 2 1 · · · 2 1 · │
|
|
2180
|
+
└───┘ └───┘ └───────────────────────────────────────────────┘
|
|
2181
|
+
Solutions found: 1
|
|
2182
|
+
status: OPTIMAL
|
|
2183
|
+
Time taken: 2.39 seconds
|
|
2184
|
+
```
|
|
2185
|
+
|
|
2186
|
+
**Solved puzzle**
|
|
2187
|
+
|
|
2188
|
+
Applying the solution to the puzzle visually:
|
|
2189
|
+
|
|
2190
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/slitherlink_solved.png" alt="Slitherlink solved" width="500">
|
|
2191
|
+
|
|
2192
|
+
---
|
|
2193
|
+
|
|
2194
|
+
## Rectangles (Puzzle Type #42)
|
|
2195
|
+
|
|
2196
|
+
Also known as Shikaku or CellBlocks.
|
|
2197
|
+
|
|
2198
|
+
* [**Play online**](https://www.chiark.greenend.org.uk/~sgtatham/puzzles/js/rect.html)
|
|
2199
|
+
|
|
2200
|
+
* [**Instructions**](https://www.chiark.greenend.org.uk/~sgtatham/puzzles/doc/rect.html#rect)
|
|
2201
|
+
|
|
2202
|
+
* [**Solver Code**](https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/rectangles)
|
|
2203
|
+
|
|
2204
|
+
<details>
|
|
2205
|
+
<summary><strong>Rules</strong></summary>
|
|
2206
|
+
|
|
2207
|
+
You have a grid of squares, with numbers written in some (but not all) of the squares. Your task is to subdivide the grid into rectangles of various sizes, such that both:
|
|
2208
|
+
|
|
2209
|
+
- (a) every rectangle contains exactly one numbered square
|
|
2210
|
+
- (b) the area of each rectangle is equal to the number written in its numbered square.
|
|
2211
|
+
|
|
2212
|
+
|
|
2213
|
+
</details>
|
|
2214
|
+
|
|
2215
|
+
**Unsolved puzzle**
|
|
2216
|
+
|
|
2217
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/rectangles_unsolved.png" alt="Rectangles unsolved" width="500">
|
|
2218
|
+
|
|
2219
|
+
Code to utilize this package and solve the puzzle:
|
|
2220
|
+
|
|
2221
|
+
```python
|
|
2222
|
+
import numpy as np
|
|
2223
|
+
from puzzle_solver import rectangles_solver as solver
|
|
2224
|
+
board = np.array([
|
|
2225
|
+
['3', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '15',' ', ' ', ' ', ' ' ],
|
|
2226
|
+
[' ', ' ', '2', '2', ' ', ' ', ' ', ' ', ' ', ' ', '11',' ', ' ', ' ', ' ', ' ', ' ', '3', '2' ],
|
|
2227
|
+
[' ', ' ', ' ', ' ', '2', ' ', ' ', ' ', '11',' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '2', ' ' ],
|
|
2228
|
+
[' ', ' ', ' ', '2', ' ', ' ', ' ', ' ', ' ', ' ', '6', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' ],
|
|
2229
|
+
[' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '3', ' ', ' ', ' ', ' ', ' ', ' ', ' ' ],
|
|
2230
|
+
[' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '2', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' ],
|
|
2231
|
+
[' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '2', ' ', ' ', ' ', ' ', ' ', ' ', ' ' ],
|
|
2232
|
+
[' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '28','4', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' ],
|
|
2233
|
+
[' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '10',' ', '10',' ', ' ', ' ', ' ', '45',' ' ],
|
|
2234
|
+
[' ', ' ', '3', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' ],
|
|
2235
|
+
[' ', '22',' ', ' ', ' ', ' ', ' ', '28',' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '17'],
|
|
2236
|
+
[' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' ],
|
|
2237
|
+
[' ', '8', '3', ' ', ' ', '2', '2', ' ', ' ', ' ', '5', ' ', ' ', '4', ' ', ' ', ' ', ' ', ' ' ],
|
|
2238
|
+
[' ', ' ', ' ', ' ', '4', ' ', ' ', '8', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '2', ' ', ' ', ' ' ],
|
|
2239
|
+
[' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '3', ' ' ],
|
|
2240
|
+
[' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' ],
|
|
2241
|
+
['2', ' ', ' ', ' ', '12',' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' ],
|
|
2242
|
+
['2', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' ],
|
|
2243
|
+
[' ', ' ', '3', '2', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '60',' ', ' ', ' ', ' ', ' ', '4', ' ' ],
|
|
2244
|
+
])
|
|
2245
|
+
binst = solver.Board(board=board)
|
|
2246
|
+
solutions = binst.solve_and_print()
|
|
2247
|
+
```
|
|
2248
|
+
|
|
2249
|
+
**Script Output**
|
|
2250
|
+
|
|
2251
|
+
```python
|
|
2252
|
+
Solution found
|
|
2253
|
+
0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1
|
|
2254
|
+
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8
|
|
2255
|
+
┌───────────┬───────────────────────────────────────────────────────────┬───┐
|
|
2256
|
+
0│ 3 │ 15 │ │
|
|
2257
|
+
├───────┬───┼───┬───────────────────────────────────────────┬───────────┤ │
|
|
2258
|
+
1│ │ 2 │ 2 │ 11 │ 3 │ 2 │
|
|
2259
|
+
│ │ │ ├───┬───────────────────────────────────────┴───┬───────┼───┤
|
|
2260
|
+
2│ │ │ │ 2 │ 11 │ 2 │ │
|
|
2261
|
+
│ ├───┴───┤ ├───────────────────────┬───┬───┬───────────┴───────┤ │
|
|
2262
|
+
3│ │ 2 │ │ 6 │ │ │ │ │
|
|
2263
|
+
│ ├───────┴───┴───────────────┬───┬───┤ │ │ │ │
|
|
2264
|
+
4│ │ │ │ │ 3 │ │ │ │
|
|
2265
|
+
│ │ │ │ │ │ │ │ │
|
|
2266
|
+
5│ │ │ │ 2 │ │ │ │ │
|
|
2267
|
+
│ │ │ ├───┴───┤ │ │ │
|
|
2268
|
+
6│ │ │ │ 2 │ │ │ │
|
|
2269
|
+
│ │ │ ├───────┤ │ │ │
|
|
2270
|
+
7│ │ 28 │ 4 │ │ │ │ │
|
|
2271
|
+
│ ├───┬───────────────────────┴───┤ │ │ │ │
|
|
2272
|
+
8│ │ │ │10 │10 │ 45 │ │
|
|
2273
|
+
│ │ │ │ │ │ │ │
|
|
2274
|
+
9│ │ 3 │ │ │ │ │ │
|
|
2275
|
+
│ │ │ │ │ │ │ │
|
|
2276
|
+
10│ 22 │ │ 28 │ │ │ │17 │
|
|
2277
|
+
│ ├───┤ │ │ │ │ │
|
|
2278
|
+
11│ │ │ │ │ │ │ │
|
|
2279
|
+
├───────┤ ├───────┬───┬───┬───────────┴───────┤ ├───────────────┬───┤ │
|
|
2280
|
+
12│ 8 │ 3 │ │ 2 │ 2 │ 5 │ │ 4 │ │ │
|
|
2281
|
+
│ │ │ │ │ ├───────────────────┴───┴───────┬───────┤ │ │
|
|
2282
|
+
13│ │ │ 4 │ │ │ 8 │ 2 │ │ │
|
|
2283
|
+
│ ├───┴───────┼───┴───┴───────────────────────────────┴───────┤ │ │
|
|
2284
|
+
14│ │ │ │ 3 │ │
|
|
2285
|
+
│ │ │ ├───┤ │
|
|
2286
|
+
15│ │ │ │ │ │
|
|
2287
|
+
├───────┤ │ │ │ │
|
|
2288
|
+
16│ 2 │ 12 │ │ │ │
|
|
2289
|
+
├───────┤ │ │ │ │
|
|
2290
|
+
17│ 2 │ │ │ │ │
|
|
2291
|
+
├───────┴───┬───────┤ │ │ │
|
|
2292
|
+
18│ 3 │ 2 │ 60 │ 4 │ │
|
|
2293
|
+
└───────────┴───────┴───────────────────────────────────────────────┴───┴───┘
|
|
2294
|
+
Solutions found: 1
|
|
2295
|
+
status: OPTIMAL
|
|
2296
|
+
Time taken: 0.01 seconds
|
|
2297
|
+
```
|
|
2298
|
+
|
|
2299
|
+
**Solved puzzle**
|
|
2300
|
+
|
|
2301
|
+
Applying the solution to the puzzle visually:
|
|
2302
|
+
|
|
2303
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/rectangles_solved.png" alt="Rectangles solved" width="500">
|
|
2304
|
+
|
|
2305
|
+
---
|
|
2306
|
+
|
|
2307
|
+
## Palisade (Puzzle Type #43)
|
|
2308
|
+
|
|
2309
|
+
* [**Play online**](https://www.chiark.greenend.org.uk/~sgtatham/puzzles/js/palisade.html)
|
|
2310
|
+
|
|
2311
|
+
* [**Instructions**](https://www.chiark.greenend.org.uk/~sgtatham/puzzles/doc/palisade.html#palisade)
|
|
2312
|
+
|
|
2313
|
+
* [**Solver Code**](https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/palisade)
|
|
2314
|
+
|
|
2315
|
+
<details>
|
|
2316
|
+
<summary><strong>Rules</strong></summary>
|
|
2317
|
+
|
|
2318
|
+
You're given a grid of N squares and a region size M, some of which contain numbers. Your goal is to subdivide the grid into (N/M) contiguous regions, where every region is of size M, such that each square containing a number is adjacent to exactly that many edges (including those between the inside and the outside of the grid).
|
|
2319
|
+
|
|
2320
|
+
</details>
|
|
2321
|
+
|
|
2322
|
+
**Unsolved puzzle**
|
|
2323
|
+
|
|
2324
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/palisade_unsolved.png" alt="Palisade unsolved" width="500">
|
|
2325
|
+
|
|
2326
|
+
Code to utilize this package and solve the puzzle:
|
|
2327
|
+
|
|
2328
|
+
(Note: it takes a few seconds for the model to be built if the region size is larger than 8 and around 10 seconds for a region size of 10)
|
|
2329
|
+
|
|
2330
|
+
```python
|
|
2331
|
+
import numpy as np
|
|
2332
|
+
from puzzle_solver import palisade_solver as solver
|
|
2333
|
+
board = np.array([
|
|
2334
|
+
['2', ' ', ' ', ' ', ' ', '3', ' ', ' ', '1', '1', '3', ' ', ' ', ' ', ' '],
|
|
2335
|
+
['3', '2', '1', ' ', '2', '3', ' ', ' ', ' ', ' ', ' ', '2', ' ', '0', ' '],
|
|
2336
|
+
[' ', ' ', ' ', '1', '1', ' ', ' ', '1', ' ', ' ', ' ', '1', ' ', ' ', ' '],
|
|
2337
|
+
[' ', '3', '2', ' ', ' ', ' ', ' ', '2', '3', ' ', ' ', ' ', '1', ' ', ' '],
|
|
2338
|
+
[' ', '0', '1', ' ', '2', ' ', ' ', '0', ' ', ' ', ' ', '1', ' ', '3', '2'],
|
|
2339
|
+
['1', '0', ' ', ' ', ' ', '2', '2', ' ', '2', ' ', '3', ' ', '0', '2', ' '],
|
|
2340
|
+
[' ', ' ', ' ', ' ', ' ', '3', ' ', ' ', ' ', '2', ' ', ' ', ' ', ' ', ' '],
|
|
2341
|
+
[' ', '1', ' ', ' ', ' ', '3', '1', ' ', '1', ' ', ' ', ' ', ' ', '1', ' '],
|
|
2342
|
+
[' ', ' ', ' ', '0', ' ', ' ', '0', ' ', ' ', '1', '2', ' ', ' ', ' ', '3'],
|
|
2343
|
+
[' ', ' ', ' ', ' ', ' ', ' ', '1', ' ', ' ', '2', ' ', ' ', '1', '2', '1'],
|
|
2344
|
+
[' ', ' ', ' ', ' ', '1', ' ', '2', '3', '1', ' ', ' ', ' ', '2', ' ', '1'],
|
|
2345
|
+
['2', ' ', '1', ' ', '2', '2', '1', ' ', ' ', '2', ' ', ' ', ' ', ' ', ' '],
|
|
2346
|
+
])
|
|
2347
|
+
binst = solver.Board(board, region_size=10)
|
|
2348
|
+
solutions = binst.solve_and_print()
|
|
2349
|
+
```
|
|
2350
|
+
|
|
2351
|
+
**Script Output**
|
|
2352
|
+
|
|
2353
|
+
```python
|
|
2354
|
+
Solution found
|
|
2355
|
+
0 0 0 0 0 0 0 0 0 0 1 1 1 1 1
|
|
2356
|
+
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4
|
|
2357
|
+
┌───────────────────┬───────────────────────┬───────────────┐
|
|
2358
|
+
0│ 2 · · · · │ 3 · · 1 1 3 │ · · · · │
|
|
2359
|
+
│ ┌───────────┐ ├───────┬───┐ ┌───┴───┐ │
|
|
2360
|
+
1│ 3 │ 2 1 · │ 2 │ 3 · │ · │ · · │ · 2 │ · 0 · │
|
|
2361
|
+
├───┘ │ └───┐ │ └───┐ └───┐ └───┐ │
|
|
2362
|
+
2│ · · · 1 │ 1 · │ · │ 1 · │ · · │ 1 · │ · · │
|
|
2363
|
+
│ ┌───┐ │ ┌───┘ │ ┌───┴───────┘ └───┐ │
|
|
2364
|
+
3│ · │ 3 │ 2 · │ · │ · · │ 2 │ 3 · · · 1 · │ · │
|
|
2365
|
+
├───┘ └───────┼───┘ ┌───┘ └───┬───────────────┬───┴───┤
|
|
2366
|
+
4│ · 0 1 · │ 2 · │ · 0 · │ · · 1 · │ 3 2 │
|
|
2367
|
+
│ ┌───┘ │ │ ┌───┐ └───┐ │
|
|
2368
|
+
5│ 1 0 · │ · · 2 │ 2 · 2 │ · │ 3 │ · 0 2 │ · │
|
|
2369
|
+
│ ┌───┴───────────┼───┬───────┴───┤ ├───┐ │ │
|
|
2370
|
+
6│ · · │ · · · 3 │ · │ · · 2 │ · │ · │ · · │ · │
|
|
2371
|
+
├───────┘ ┌───────────┤ └───┐ │ │ └───────┘ │
|
|
2372
|
+
7│ · 1 · │ · · 3 │ 1 · │ 1 · │ · │ · · 1 · │
|
|
2373
|
+
│ ┌───┘ ┌───┘ │ │ └───────┐ ┌───┤
|
|
2374
|
+
8│ · · │ · 0 · │ · 0 · │ · 1 │ 2 · · │ · │ 3 │
|
|
2375
|
+
│ ┌───┘ ┌───┤ ├───┐ └───┐ ├───┘ │
|
|
2376
|
+
9│ · │ · · · │ · │ · 1 · │ · │ 2 · │ · 1 │ 2 1 │
|
|
2377
|
+
├───┤ ┌───────┘ ├───────┐ │ └───┐ │ │ │
|
|
2378
|
+
10│ · │ · │ · · 1 │ · 2 │ 3 │ 1 · │ · │ · 2 │ · 1 │
|
|
2379
|
+
│ └───┘ │ └───┘ ├───┴───────┘ │
|
|
2380
|
+
11│ 2 · 1 · 2 │ 2 1 · · 2 │ · · · · · │
|
|
2381
|
+
└───────────────────┴───────────────────┴───────────────────┘
|
|
2382
|
+
Solutions found: 1
|
|
2383
|
+
status: OPTIMAL
|
|
2384
|
+
Time taken: 11.94 seconds
|
|
2385
|
+
```
|
|
2386
|
+
|
|
2387
|
+
**Solved puzzle**
|
|
2388
|
+
|
|
2389
|
+
Applying the solution to the puzzle visually:
|
|
2390
|
+
|
|
2391
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/palisade_solved.png" alt="Palisade solved" width="500">
|
|
2392
|
+
|
|
2393
|
+
---
|
|
2394
|
+
|
|
2395
|
+
## Heyawake (Puzzle Type #46)
|
|
2396
|
+
|
|
2397
|
+
* [**Play online**](https://www.puzzle-heyawake.com/)
|
|
2398
|
+
|
|
2399
|
+
* [**Solver Code**](https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/heyawake)
|
|
2400
|
+
|
|
2401
|
+
<details>
|
|
2402
|
+
<summary><strong>Rules</strong></summary>
|
|
2403
|
+
|
|
2404
|
+
You have to color the cells of the grid in black and white according to the rules:
|
|
2405
|
+
- Regions with a number should contain black cells matching the number.
|
|
2406
|
+
- 2 black cells cannot be adjacent horizontally or vertically.
|
|
2407
|
+
- A straight (orthogonal) line of connected white cells cannot span across more than 2 regions.
|
|
2408
|
+
- All white cells should be connected in a single group.
|
|
2409
|
+
|
|
2410
|
+
</details>
|
|
2411
|
+
|
|
2412
|
+
**Unsolved puzzle**
|
|
2413
|
+
|
|
2414
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/heyawake_unsolved.png" alt="Heyawake unsolved" width="500">
|
|
2415
|
+
|
|
2416
|
+
Code to utilize this package and solve the puzzle:
|
|
2417
|
+
|
|
2418
|
+
```python
|
|
2419
|
+
import numpy as np
|
|
2420
|
+
from puzzle_solver import heyawake_solver as solver
|
|
2421
|
+
board = np.array([
|
|
2422
|
+
['00', '01', '02', '03', '04', '04', '04', '04', '04', '04', '04', '04', '04', '04', '05', '05', '06', '06', '07', '07'],
|
|
2423
|
+
['00', '08', '02', '03', '09', '09', '10', '10', '10', '11', '11', '12', '12', '12', '05', '05', '06', '06', '07', '07'],
|
|
2424
|
+
['00', '08', '02', '03', '09', '09', '13', '13', '13', '11', '11', '12', '12', '12', '14', '14', '14', '15', '15', '16'],
|
|
2425
|
+
['17', '17', '17', '03', '09', '09', '18', '18', '19', '11', '11', '20', '20', '21', '21', '22', '22', '15', '15', '16'],
|
|
2426
|
+
['17', '17', '17', '23', '23', '23', '23', '23', '19', '11', '11', '24', '24', '21', '21', '25', '25', '25', '25', '26'],
|
|
2427
|
+
['27', '28', '28', '23', '23', '23', '23', '23', '29', '29', '30', '31', '32', '32', '32', '25', '25', '25', '25', '26'],
|
|
2428
|
+
['27', '28', '28', '33', '34', '34', '35', '35', '35', '36', '30', '31', '32', '32', '32', '25', '25', '25', '25', '26'],
|
|
2429
|
+
['27', '28', '28', '33', '34', '34', '35', '35', '35', '37', '37', '31', '32', '32', '32', '25', '25', '25', '25', '38'],
|
|
2430
|
+
['27', '28', '28', '39', '39', '39', '40', '40', '40', '41', '41', '31', '42', '42', '42', '42', '42', '43', '43', '38'],
|
|
2431
|
+
['27', '28', '28', '39', '39', '39', '40', '40', '40', '41', '41', '44', '44', '44', '44', '44', '44', '43', '43', '38'],
|
|
2432
|
+
['27', '45', '45', '39', '39', '39', '46', '46', '47', '41', '41', '44', '44', '44', '44', '44', '44', '48', '48', '48'],
|
|
2433
|
+
['49', '45', '45', '50', '50', '50', '46', '46', '47', '41', '41', '51', '52', '52', '52', '52', '53', '53', '53', '54'],
|
|
2434
|
+
['49', '55', '56', '57', '57', '57', '58', '58', '58', '41', '41', '51', '52', '52', '52', '52', '53', '53', '53', '54'],
|
|
2435
|
+
['49', '55', '59', '57', '57', '57', '58', '58', '58', '60', '60', '61', '61', '62', '62', '63', '63', '63', '63', '54'],
|
|
2436
|
+
['49', '64', '64', '57', '57', '57', '58', '58', '58', '60', '60', '61', '61', '62', '62', '63', '63', '63', '63', '54'],
|
|
2437
|
+
['49', '64', '64', '65', '65', '66', '58', '58', '58', '60', '60', '61', '61', '67', '67', '63', '63', '63', '63', '54'],
|
|
2438
|
+
['49', '64', '64', '65', '65', '66', '58', '58', '58', '60', '60', '61', '61', '67', '67', '68', '68', '69', '70', '54'],
|
|
2439
|
+
['49', '71', '71', '72', '72', '72', '73', '74', '74', '74', '75', '76', '76', '67', '67', '68', '68', '69', '77', '54'],
|
|
2440
|
+
['49', '71', '71', '72', '72', '72', '73', '74', '74', '74', '75', '78', '78', '78', '78', '79', '80', '80', '77', '54'],
|
|
2441
|
+
['81', '81', '81', '81', '81', '81', '81', '82', '82', '82', '75', '83', '83', '83', '83', '79', '80', '80', '77', '54']
|
|
2442
|
+
])
|
|
2443
|
+
region_to_clue = {
|
|
2444
|
+
'04': 4, '09': 0, '06': 0, '16': 0, '13': 2, '24': 0, '32': 5, '27': 3, '34': 0,
|
|
2445
|
+
'39': 3, '37': 0, '41': 3, '38': 2, '43': 0, '44': 4, '54': 3, '53': 2, '70': 1,
|
|
2446
|
+
'80': 2, '67': 1, '83': 2, '82': 2, '73': 0, '72': 1, '71': 2, '64': 1, '56': 1,
|
|
2447
|
+
'45': 0, '57': 2, '58': 5, '66': 0, '60': 3, '61': 2
|
|
2448
|
+
}
|
|
2449
|
+
binst = solver.Board(board=board, region_to_clue=region_to_clue)
|
|
2450
|
+
solutions = binst.solve_and_print()
|
|
2451
|
+
```
|
|
2452
|
+
|
|
2453
|
+
**Script Output**
|
|
2454
|
+
|
|
2455
|
+
```python
|
|
2456
|
+
Solution found
|
|
2457
|
+
0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1
|
|
2458
|
+
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9
|
|
2459
|
+
┌───┬───┬───┬───┬───────────────────────────────────────┬───────┬───────┬───────┐
|
|
2460
|
+
0│ │ │▒▒▒│ │ 4 ▒▒▒ 4 ▒▒▒ 4 4 ▒▒▒ 4 ▒▒▒ 4 │ ▒▒▒│ 0 0 │ │
|
|
2461
|
+
│ ├───┤ │ ├───────┬───────────┬───────┬───────────┤ │ │ │
|
|
2462
|
+
1│▒▒▒│ │ │▒▒▒│ 0 0 │ │▒▒▒ │ │▒▒▒ │ 0 0 │▒▒▒ │
|
|
2463
|
+
│ │ │ │ │ ├───────────┤ │ ├───────┴───┬───┴───┬───┤
|
|
2464
|
+
2│ │ │▒▒▒│ │ 0 0 │▒▒▒ 2 ▒▒▒│ │ ▒▒▒ │ ▒▒▒ │▒▒▒ │ 0 │
|
|
2465
|
+
├───┴───┴───┤ │ ├───────┬───┤ ├───────┬───┴───┬───────┤ │ │
|
|
2466
|
+
3│ ▒▒▒ │▒▒▒│ 0 0 │ ▒▒▒│ │ │▒▒▒ │▒▒▒ │ ▒▒▒│ │ 0 │
|
|
2467
|
+
│ ├───┴───────┴───────┤ │ ├───────┤ ├───────┴───────┼───┤
|
|
2468
|
+
4│ │ ▒▒▒ │▒▒▒│ ▒▒▒│ 0 0 │ │▒▒▒ │▒▒▒│
|
|
2469
|
+
├───┬───────┤ ├───┴───┬───┼───┬───┴───────┤ │ │
|
|
2470
|
+
5│▒▒▒│ │ ▒▒▒ │ ▒▒▒│ │ │▒▒▒ 5 ▒▒▒│ ▒▒▒│ │
|
|
2471
|
+
│ │ ├───┬───────┬───────┴───┬───┤ │ │ │ │ │
|
|
2472
|
+
6│ 3 │ ▒▒▒│ │ 0 0 │▒▒▒ │ │▒▒▒│ │ 5 ▒▒▒ 5 │ ▒▒▒ │ │
|
|
2473
|
+
│ │ │ │ │ ├───┴───┤ │ │ ├───┤
|
|
2474
|
+
7│▒▒▒│ │▒▒▒│ 0 0 │ ▒▒▒│ 0 0 │ │▒▒▒ 5 ▒▒▒│ ▒▒▒ │▒▒▒│
|
|
2475
|
+
│ │ ├───┴───────┼───────────┼───────┤ ├───────────┴───────┬───────┤ │
|
|
2476
|
+
8│ 3 │ ▒▒▒│ 3 ▒▒▒ 3 │ ▒▒▒ │▒▒▒ 3 │▒▒▒│ ▒▒▒│ 0 0 │ 2 │
|
|
2477
|
+
│ │ │ │ │ ├───┴───────────────────┤ │ │
|
|
2478
|
+
9│ 3 │▒▒▒ │ 3 3 ▒▒▒│ │ 3 ▒▒▒│ 4 4 ▒▒▒ 4 ▒▒▒ 4 │ 0 0 │▒▒▒│
|
|
2479
|
+
│ ├───────┤ ├───────┬───┤ │ ├───────┴───┤
|
|
2480
|
+
10│▒▒▒│ 0 0 │ 3 ▒▒▒ 3 │▒▒▒ │ │▒▒▒ 3 │▒▒▒ 4 4 ▒▒▒ 4 4 │ ▒▒▒ │
|
|
2481
|
+
├───┤ ├───────────┤ │ │ ├───┬───────────────┬───┴───────┬───┤
|
|
2482
|
+
11│ │ 0 0 │▒▒▒ │ │▒▒▒│ 3 3 │ │▒▒▒ ▒▒▒│ 2 ▒▒▒ 2 │ 3 │
|
|
2483
|
+
│ ├───┬───┼───────────┼───────┴───┤ │ │ │ │ │
|
|
2484
|
+
12│ │ │▒▒▒│ 2 2 ▒▒▒│ 5 ▒▒▒ 5 │ 3 3 │▒▒▒│ │▒▒▒ 2 2 │▒▒▒│
|
|
2485
|
+
│ │ ├───┤ │ ├───────┼───┴───┬───────┬───┴───────────┤ │
|
|
2486
|
+
13│ │▒▒▒│ │ 2 2 2 │▒▒▒ 5 5 │▒▒▒ 3 │ 2 2 │▒▒▒ │ ▒▒▒ │ 3 │
|
|
2487
|
+
│ ├───┴───┤ │ │ │ │ │ │ │
|
|
2488
|
+
14│ │ 1 ▒▒▒│ 2 2 ▒▒▒│ 5 ▒▒▒ 5 │ 3 ▒▒▒│ 2 2 │ ▒▒▒│ │▒▒▒│
|
|
2489
|
+
│ │ ├───────┬───┤ │ │ ├───────┤ │ │
|
|
2490
|
+
15│▒▒▒│ 1 1 │ ▒▒▒│ 0 │ 5 5 5 │▒▒▒ 3 │▒▒▒ 2 │ 1 1 │▒▒▒ │ 3 │
|
|
2491
|
+
│ │ │ │ │ │ │ │ ├───────┬───┬───┤ │
|
|
2492
|
+
16│ │ 1 1 │▒▒▒ │ 0 │▒▒▒ 5 ▒▒▒│ 3 3 │ 2 ▒▒▒│ 1 1 │ ▒▒▒│ │▒▒▒│ 3 │
|
|
2493
|
+
│ ├───────┼───────┴───┼───┬───────┴───┬───┼───────┤ │ │ ├───┤ │
|
|
2494
|
+
17│ │ 2 ▒▒▒│ 1 1 1 │ 0 │▒▒▒ │ │▒▒▒ │▒▒▒ 1 │ │▒▒▒│ │ 3 │
|
|
2495
|
+
│ │ │ │ │ │ ├───────┴───────┼───┬───┴───┤ │ │
|
|
2496
|
+
18│ │▒▒▒ 2 │ 1 1 ▒▒▒│ 0 │ │▒▒▒│ │ │▒▒▒ 2 │ │▒▒▒│
|
|
2497
|
+
├───┴───────┴───────────┴───┼───────────┤ ├───────────────┤ │ │ │ │
|
|
2498
|
+
19│ ▒▒▒ │▒▒▒ 2 ▒▒▒│ │ 2 ▒▒▒ 2 ▒▒▒│ │ 2 ▒▒▒│ │ 3 │
|
|
2499
|
+
└───────────────────────────┴───────────┴───┴───────────────┴───┴───────┴───┴───┘
|
|
2500
|
+
Solutions found: 1
|
|
2501
|
+
status: OPTIMAL
|
|
2502
|
+
Time taken: 6.72 seconds
|
|
2503
|
+
```
|
|
2504
|
+
|
|
2505
|
+
**Solved puzzle**
|
|
2506
|
+
|
|
2507
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/heyawake_solved.png" alt="Heyawake solved" width="500">
|
|
2508
|
+
|
|
2509
|
+
---
|
|
2510
|
+
|
|
2511
|
+
## Shingoki (Puzzle Type #47)
|
|
2512
|
+
|
|
2513
|
+
Also known as Semaphores.
|
|
2514
|
+
|
|
2515
|
+
* [**Play online**](https://www.puzzle-shingoki.com/)
|
|
2516
|
+
|
|
2517
|
+
* [**Solver Code**](https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/shingoki)
|
|
2518
|
+
|
|
2519
|
+
<details>
|
|
2520
|
+
<summary><strong>Rules</strong></summary>
|
|
2521
|
+
|
|
2522
|
+
You have to draw lines between the dots to form a single loop without crossings or branches. The loop should pass through all black and white circles in such a way that:
|
|
2523
|
+
- White circles must be passed through in a straight line
|
|
2524
|
+
- Black circles must be turned upon
|
|
2525
|
+
- The numbers in the circles show the sum of the lengths of the 2 straight lines going out of that circle.
|
|
2526
|
+
|
|
2527
|
+
</details>
|
|
2528
|
+
|
|
2529
|
+
**Unsolved puzzle**
|
|
2530
|
+
|
|
2531
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/shingoki_unsolved.png" alt="Shingoki unsolved" width="500">
|
|
2532
|
+
|
|
2533
|
+
Code to utilize this package and solve the puzzle:
|
|
2534
|
+
|
|
2535
|
+
```python
|
|
2536
|
+
import numpy as np
|
|
2537
|
+
from puzzle_solver import shingoki_solver as solver
|
|
2538
|
+
board = np.array([
|
|
2539
|
+
[' ', ' ', ' ', ' ', ' ', '4B', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '],
|
|
2540
|
+
[' ', ' ', ' ', ' ', '5B', ' ', ' ', '2B', ' ', ' ', '3B', ' ', ' ', ' ', '3W', ' ', ' ', ' ', ' ', '2B', ' '],
|
|
2541
|
+
['2B', '2B', ' ', '2W', ' ', ' ', ' ', ' ', ' ', ' ', '2B', ' ', '2B', ' ', ' ', ' ', '3B', '5W', ' ', ' ', '11W'],
|
|
2542
|
+
[' ', ' ', ' ', ' ', ' ', '3B', ' ', '3B', ' ', ' ', ' ', ' ', '2B', ' ', ' ', ' ', ' ', ' ', '3W', ' ', ' '],
|
|
2543
|
+
[' ', '2W', ' ', ' ', '2B', ' ', '2W', ' ', '3W', ' ', '2W', '2B', '2B', ' ', ' ', ' ', ' ', ' ', ' ', '8W', ' '],
|
|
2544
|
+
[' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '6B', ' ', ' ', ' ', ' ', '4B', '2W', ' ', ' ', ' ', ' ', ' '],
|
|
2545
|
+
[' ', ' ', ' ', '2B', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '2W', ' ', ' ', ' ', '4B', ' ', ' '],
|
|
2546
|
+
[' ', '2B', '2W', ' ', ' ', ' ', '3B', ' ', ' ', ' ', ' ', '3W', ' ', ' ', ' ', ' ', ' ', ' ', '3B', ' ', ' '],
|
|
2547
|
+
['4W', '3B', ' ', ' ', '3W', ' ', ' ', ' ', ' ', ' ', '3B', ' ', '6B', ' ', ' ', ' ', '2B', ' ', ' ', ' ', ' '],
|
|
2548
|
+
[' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '2W', '7B', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '],
|
|
2549
|
+
[' ', ' ', ' ', '3W', ' ', '3W', '4W', '5B', ' ', ' ', ' ', ' ', '5W', ' ', '4W', ' ', ' ', ' ', '2W', ' ', ' '],
|
|
2550
|
+
['7B', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '3B', ' '],
|
|
2551
|
+
[' ', ' ', ' ', ' ', '2B', ' ', '4W', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '5B', ' ', ' ', ' '],
|
|
2552
|
+
[' ', ' ', '2W', ' ', ' ', '2B', ' ', '4W', '3W', ' ', ' ', ' ', ' ', ' ', ' ', '5B', '2B', ' ', '3W', ' ', ' '],
|
|
2553
|
+
[' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '3B', ' ', '7W', ' ', '2B', '5B', ' ', ' ', ' ', ' ', ' ', ' '],
|
|
2554
|
+
[' ', ' ', ' ', ' ', ' ', '3B', '2B', ' ', ' ', ' ', '3W', ' ', '2B', ' ', ' ', ' ', '2W', ' ', ' ', ' ', ' '],
|
|
2555
|
+
[' ', ' ', ' ', '2W', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '3B', ' '],
|
|
2556
|
+
[' ', '4W', ' ', ' ', '2B', '3B', ' ', ' ', ' ', '2B', '4B', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '3W', ' ', ' '],
|
|
2557
|
+
['7W', ' ', '3B', ' ', ' ', '2B', ' ', ' ', ' ', '4B', ' ', ' ', ' ', ' ', '2W', '3B', ' ', '2B', ' ', ' ', ' '],
|
|
2558
|
+
[' ', ' ', ' ', '3W', ' ', '3W', ' ', ' ', '2B', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '3W', ' ', '2W', ' ', ' '],
|
|
2559
|
+
[' ', '2B', ' ', ' ', ' ', ' ', '5W', ' ', ' ', ' ', ' ', '5W', ' ', ' ', ' ', '6B', ' ', ' ', ' ', ' ', ' '],
|
|
2560
|
+
])
|
|
2561
|
+
binst = solver.Board(board=board)
|
|
2562
|
+
solutions = binst.solve_and_print()
|
|
2563
|
+
```
|
|
2564
|
+
|
|
2565
|
+
**Script Output**
|
|
2566
|
+
|
|
2567
|
+
Note that the solver is much slower for large puzzles like this example and take ~3 minutes to find a valid solution and ~7 minutes to verify that no other solutions exist.
|
|
2568
|
+
|
|
2569
|
+
```python
|
|
2570
|
+
Solution found
|
|
2571
|
+
0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 2
|
|
2572
|
+
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0
|
|
2573
|
+
|
|
2574
|
+
0 . . . . . 4B───────────┐ ┌───────────────────────────┐ ┌───┐ ┌───┐
|
|
2575
|
+
│ │ │ │ │ │ │ │
|
|
2576
|
+
1 ┌──────────────5B └───┐ 2B───┘ │ 3B───────┐ ┌──3W───────┘ │ └──2B │
|
|
2577
|
+
│ │ │ │ │ │ │ │ │ │
|
|
2578
|
+
2 2B──2B ┌──2W───┘ ┌───┘ └───┐ │ 2B───┐ 2B───┘ . ┌──3B 5W ┌───┐ 11W
|
|
2579
|
+
│ │ │ │ │ │ │ │ │ │ │ │
|
|
2580
|
+
3 ┌───┘ └───┐ . 3B──────3B │ │ ┌───┘ 2B───┐ ┌───┘ │ │ 3W │ │
|
|
2581
|
+
│ │ │ │ │ │ │ │ │ │ │ │ │ │
|
|
2582
|
+
4 └──2W───┐ └──2B ┌──2W───┘ 3W │ 2W 2B──2B └───┘ ┌───┘ │ │ 8W │
|
|
2583
|
+
│ │ │ │ │ │ │ │ │ │ │ │
|
|
2584
|
+
5 ┌───────┘ ┌───┘ └───────┐ └──6B └───┘ ┌──────4B 2W . └───┘ │ │
|
|
2585
|
+
│ │ │ │ │ │ │ │
|
|
2586
|
+
6 └───┐ ┌──2B . ┌───┐ └───────────────────┘ . 2W └──────────4B │ │
|
|
2587
|
+
│ │ │ │ │ │ │ │
|
|
2588
|
+
7 ┌──2B 2W . ┌───┘ 3B───────┐ . ┌──3W───────┐ └───┐ ┌──────3B │ │
|
|
2589
|
+
│ │ │ │ │ │ │ │ │ │
|
|
2590
|
+
8 4W 3B───┘ . 3W ┌───────┐ └──────3B ┌──6B │ ┌───┘ 2B───┐ . │ │
|
|
2591
|
+
│ │ │ │ │ │ │ │ │ │ │ │
|
|
2592
|
+
9 │ │ . . │ │ ┌───┘ ┌──2W──7B │ │ │ │ ┌───┐ │ . │ │
|
|
2593
|
+
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
|
|
2594
|
+
10 │ └──────3W───┘ 3W 4W 5B───┘ . │ │ 5W │ 4W │ │ └──2W───┘ │
|
|
2595
|
+
│ │ │ │ │ │ │ │ │ │ │ │
|
|
2596
|
+
11 7B───────────┐ ┌───┘ │ │ . . │ │ │ │ │ │ └───────┐ 3B───┘
|
|
2597
|
+
│ │ │ │ │ │ │ │ │ │ │ │
|
|
2598
|
+
12 ┌───┐ . └──2B . 4W │ ┌───┐ │ │ │ └───┘ │ ┌──5B │ │ .
|
|
2599
|
+
│ │ │ │ │ │ │ │ │ │ │ │ │ │
|
|
2600
|
+
13 │ └──2W───┐ . 2B───┘ 4W 3W │ │ │ └───┐ . 5B──2B │ 3W └───┐
|
|
2601
|
+
│ │ │ │ │ │ │ │ │ │ │ │
|
|
2602
|
+
14 │ ┌───┐ │ . └───────┘ │ 3B───┘ 7W ┌──2B 5B───────┐ │ └───┐ │
|
|
2603
|
+
│ │ │ │ │ │ │ │ │ │ │ │
|
|
2604
|
+
15 │ │ │ └──────3B 2B───┐ └──────3W───┘ 2B───┐ │ . 2W │ ┌───┘ │
|
|
2605
|
+
│ │ │ │ │ │ │ │ │ │ │ │
|
|
2606
|
+
16 │ │ └──2W───┐ └───┘ │ . ┌───┐ . . │ │ . └───┘ │ 3B───┘
|
|
2607
|
+
│ │ │ │ │ │ │ │ │ │
|
|
2608
|
+
17 │ 4W . ┌──2B 3B───────┘ ┌──2B 4B───────────┘ └───┐ ┌───┐ 3W │ .
|
|
2609
|
+
│ │ │ │ │ │ │ │ │ │
|
|
2610
|
+
18 7W └──3B │ ┌──2B . ┌───┘ 4B───────────┐ ┌──2W──3B │ 2B───┘ └───┐
|
|
2611
|
+
│ │ │ │ │ │ │ │ │ │
|
|
2612
|
+
19 └───┐ │ 3W └──3W───────┘ 2B───┘ ┌───────┘ └───────┐ 3W ┌──2W───┐ │
|
|
2613
|
+
│ │ │ │ │ │ │ │ │ │
|
|
2614
|
+
20 . 2B───┘ └──────────5W───────┘ . └──5W──────────────6B └───┘ . └───┘
|
|
2615
|
+
|
|
2616
|
+
Solutions found: 1
|
|
2617
|
+
status: OPTIMAL
|
|
2618
|
+
Time taken: 72.80 seconds
|
|
2619
|
+
```
|
|
2620
|
+
|
|
2621
|
+
**Solved puzzle**
|
|
2622
|
+
|
|
2623
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/shingoki_solved.png" alt="Shingoki solved" width="500">
|
|
2624
|
+
|
|
2625
|
+
---
|
|
2626
|
+
|
|
2627
|
+
## Shakashaka (Puzzle Type #50)
|
|
2628
|
+
|
|
2629
|
+
Also known as Proof of Quilt.
|
|
2630
|
+
|
|
2631
|
+
* [**Play online**](https://www.puzzle-shakashaka.com/)
|
|
2632
|
+
|
|
2633
|
+
* [**Solver Code**](https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/shakashaka)
|
|
2634
|
+
|
|
2635
|
+
<details>
|
|
2636
|
+
<summary><strong>Rules</strong></summary>
|
|
2637
|
+
|
|
2638
|
+
Shakashaka is played on a rectangular grid. The grid has both black cells and white cells in it.
|
|
2639
|
+
The objective is to place black triangles in the white cell in such a way so that they form white rectangular (or square) areas.
|
|
2640
|
+
- The triangles are right angled and occupy half of the white square divided diagonally.
|
|
2641
|
+
- You can place triangles only in white cells
|
|
2642
|
+
- The numbers in the black cells indicate how many triangles are adjacent, vertically and horizontally.
|
|
2643
|
+
- The white rectangles can be either straight or rotated at 45°
|
|
2644
|
+
|
|
2645
|
+
</details>
|
|
2646
|
+
|
|
2647
|
+
**Unsolved puzzle**
|
|
2648
|
+
|
|
2649
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/shakashaka_unsolved.png" alt="Shakashaka unsolved" width="500">
|
|
2650
|
+
|
|
2651
|
+
Code to utilize this package and solve the puzzle:
|
|
2652
|
+
|
|
2653
|
+
```python
|
|
2654
|
+
import numpy as np
|
|
2655
|
+
from puzzle_solver import shakashaka_solver as solver
|
|
2656
|
+
board = np.array([
|
|
2657
|
+
[' ', ' ', 'B', ' ', '1', ' ', ' ', '1', ' ', ' ', 'B', 'B', ' ', ' ', ' ', '2', ' ', ' ', ' ', ' ', 'B', ' ', 'B', ' ', ' '],
|
|
2658
|
+
[' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'B', ' ', ' ', ' ', ' ', 'B', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '],
|
|
2659
|
+
[' ', ' ', ' ', ' ', ' ', ' ', ' ', '3', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '4', ' ', ' ', ' ', ' ', ' ', ' ', ' '],
|
|
2660
|
+
[' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'B', ' ', ' ', ' ', ' ', ' ', ' ', '3', ' ', ' ', ' ', ' ', ' ', 'B'],
|
|
2661
|
+
['1', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '2', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '4', ' ', ' ', ' ', ' '],
|
|
2662
|
+
[' ', ' ', '3', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'B', ' ', ' '],
|
|
2663
|
+
[' ', ' ', ' ', '1', ' ', ' ', '2', ' ', ' ', ' ', ' ', 'B', ' ', '3', ' ', ' ', ' ', 'B', ' ', ' ', ' ', ' ', ' ', ' ', ' '],
|
|
2664
|
+
[' ', ' ', ' ', 'B', ' ', ' ', 'B', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '3', ' ', ' ', ' ', '4', ' ', ' ', ' ', 'B'],
|
|
2665
|
+
[' ', 'B', '2', ' ', ' ', 'B', ' ', ' ', ' ', ' ', '3', ' ', ' ', ' ', '2', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '4', ' ', ' '],
|
|
2666
|
+
['B', ' ', ' ', ' ', ' ', 'B', ' ', ' ', '1', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '],
|
|
2667
|
+
['0', ' ', ' ', 'B', ' ', ' ', ' ', ' ', 'B', ' ', ' ', ' ', 'B', 'B', 'B', ' ', ' ', ' ', ' ', '3', ' ', ' ', ' ', ' ', 'B'],
|
|
2668
|
+
['0', ' ', ' ', 'B', ' ', ' ', ' ', 'B', ' ', ' ', ' ', '1', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '3', ' '],
|
|
2669
|
+
[' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '2', ' ', 'B', ' ', ' ', 'B', ' ', ' ', ' ', ' ', ' ', 'B', ' ', ' ', ' '],
|
|
2670
|
+
[' ', ' ', ' ', ' ', ' ', 'B', ' ', ' ', 'B', ' ', 'B', ' ', 'B', ' ', 'B', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '],
|
|
2671
|
+
[' ', ' ', ' ', ' ', '4', ' ', ' ', '3', ' ', 'B', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'B', ' ', ' ', '4', ' ', ' ', ' ', ' '],
|
|
2672
|
+
[' ', 'B', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'B', ' ', ' ', ' ', ' ', '3', ' ', ' ', 'B', ' ', ' ', ' ', ' ', ' ', '3'],
|
|
2673
|
+
['B', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'B', ' ', ' ', ' ', '1', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '4', ' ', ' ', ' '],
|
|
2674
|
+
[' ', ' ', 'B', ' ', 'B', ' ', ' ', '2', ' ', ' ', ' ', ' ', ' ', 'B', ' ', ' ', 'B', ' ', ' ', 'B', ' ', ' ', ' ', ' ', ' '],
|
|
2675
|
+
[' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '0', ' ', ' ', ' ', ' ', ' ', 'B', ' ', ' '],
|
|
2676
|
+
['B', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'B', ' ', ' ', ' ', ' ', ' ', ' ', 'B', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '],
|
|
2677
|
+
[' ', ' ', ' ', ' ', ' ', ' ', '2', 'B', ' ', ' ', '2', ' ', ' ', ' ', ' ', 'B', ' ', ' ', ' ', ' ', '1', ' ', ' ', ' ', ' '],
|
|
2678
|
+
[' ', ' ', ' ', '3', ' ', ' ', ' ', '2', ' ', ' ', '1', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'B', ' ', 'B', ' ', ' ', ' ', ' '],
|
|
2679
|
+
[' ', ' ', 'B', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'B', ' ', ' ', ' ', 'B', ' ', ' ', 'B', ' ', ' ', ' ', ' ', ' ', ' ', '2'],
|
|
2680
|
+
['2', ' ', ' ', 'B', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '3', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'B', ' ', ' ', ' ', ' '],
|
|
2681
|
+
[' ', ' ', ' ', ' ', ' ', ' ', '3', ' ', ' ', ' ', ' ', ' ', '2', ' ', ' ', ' ', ' ', '0', ' ', ' ', ' ', ' ', ' ', '2', ' '],
|
|
2682
|
+
])
|
|
2683
|
+
binst = solver.Board(board=board)
|
|
2684
|
+
solutions = binst.solve_and_print()
|
|
2685
|
+
```
|
|
2686
|
+
|
|
2687
|
+
**Script Output**
|
|
2688
|
+
|
|
2689
|
+
(Note: It took so long to find a good text-based visualization to the solution that is both readable and looks good, this isn't the best but it finally does the job)
|
|
2690
|
+
|
|
2691
|
+
```python
|
|
2692
|
+
Solution found
|
|
2693
|
+
┌──────┬──────┬──────┬──────┬──────┬──────┬──────┬──────┬──────┬──────┬──────┬──────┬──────┬──────┬──────┬──────┬──────┬──────┬──────┬──────┬──────┬──────┬──────┬──────┬──────┐
|
|
2694
|
+
│ /█│█\ │ │██████│ │ /█│█\ │ │██████│██████│ │ │██████│ /█│█\ │ │██████│ /█│█\ │██████│ │██████│ │ /█│█\ │
|
|
2695
|
+
│ /███│███\ │ . │██████│ 1 │ /███│███\ │ 1 │██████│██████│ . │ . │██████│ /███│███\ │ 2 │██████│ /███│███\ │██████│ . │██████│ . │ /███│███\ │
|
|
2696
|
+
│/█████│█████\│ │██████│ │/█████│█████\│ │██████│██████│ │ │██████│/█████│█████\│ │██████│/█████│█████\│██████│ │██████│ │/█████│█████\│
|
|
2697
|
+
├──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┤
|
|
2698
|
+
│\█████│█████/│ /█│█\ │██████│\█████│█████/│██████│ /█│█\ │██████│ │██████│\█████│██████│█\ │ │\█████│██████│█\ │██████│ /█│█\ │\█████│█████/│
|
|
2699
|
+
│ \███│███/ │ /███│███\ │██████│ \███│███/ │██████│ /███│███\ │██████│ . │██████│ \███│██████│███\ │ . │ \███│██████│███\ │██████│ /███│███\ │ \███│███/ │
|
|
2700
|
+
│ \█│█/ │/█████│█████\│██████│ \█│█/ │██████│/█████│█████\│██████│ │██████│ \█│██████│█████\│ │ \█│██████│█████\│██████│/█████│█████\│ \█│█/ │
|
|
2701
|
+
├──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┤
|
|
2702
|
+
│██████│ /█│██████│██████│█\ │ /█│█\ │ │\█████│██████│█\ │██████│ /█│█\ │\█████│██████│█\ │ │\█████│█████/│ /█│██████│██████│█\ │██████│
|
|
2703
|
+
│██████│ /███│██████│██████│███\ │ /███│███\ │ 3 │ \███│██████│███\ │██████│ /███│███\ │ \███│██████│███\ │ 4 │ \███│███/ │ /███│██████│██████│███\ │██████│
|
|
2704
|
+
│██████│/█████│██████│██████│█████\│/█████│█████\│ │ \█│██████│█████\│██████│/█████│█████\│ \█│██████│█████\│ │ \█│█/ │/█████│██████│██████│█████\│██████│
|
|
2705
|
+
├──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┤
|
|
2706
|
+
│██████│\█████│██████│██████│█████/│\█████│█████/│ /█│█\ │\█████│█████/│ │\█████│█████/│██████│\█████│██████│█\ │ │██████│\█████│██████│██████│█████/│ │
|
|
2707
|
+
│██████│ \███│██████│██████│███/ │ \███│███/ │ /███│███\ │ \███│███/ │ . │ \███│███/ │██████│ \███│██████│███\ │ 3 │██████│ \███│██████│██████│███/ │ . │
|
|
2708
|
+
│██████│ \█│██████│██████│█/ │ \█│█/ │/█████│█████\│ \█│█/ │ │ \█│█/ │██████│ \█│██████│█████\│ │██████│ \█│██████│██████│█/ │ │
|
|
2709
|
+
├──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┤
|
|
2710
|
+
│ │██████│\█████│█████/│ /█│█\ │ /█│██████│█████/│██████│ │ /█│█\ │ /█│█\ │██████│\█████│█████/│ /█│█\ │ │\█████│█████/│██████│██████│
|
|
2711
|
+
│ 1 │██████│ \███│███/ │ /███│███\ │ /███│██████│███/ │██████│ 2 │ /███│███\ │ /███│███\ │██████│ \███│███/ │ /███│███\ │ 4 │ \███│███/ │██████│██████│
|
|
2712
|
+
│ │██████│ \█│█/ │/█████│█████\│/█████│██████│█/ │██████│ │/█████│█████\│/█████│█████\│██████│ \█│█/ │/█████│█████\│ │ \█│█/ │██████│██████│
|
|
2713
|
+
├──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┤
|
|
2714
|
+
│ /█│█\ │ │██████│\█████│█████/│\█████│█████/│ /█│█\ │██████│\█████│█████/│\█████│█████/│ /█│█\ │██████│\█████│█████/│ /█│█\ │ │ /█│█\ │
|
|
2715
|
+
│ /███│███\ │ 3 │██████│ \███│███/ │ \███│███/ │ /███│███\ │██████│ \███│███/ │ \███│███/ │ /███│███\ │██████│ \███│███/ │ /███│███\ │ . │ /███│███\ │
|
|
2716
|
+
│/█████│█████\│ │██████│ \█│█/ │ \█│█/ │/█████│█████\│██████│ \█│█/ │ \█│█/ │/█████│█████\│██████│ \█│█/ │/█████│█████\│ │/█████│█████\│
|
|
2717
|
+
├──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┤
|
|
2718
|
+
│\█████│██████│█\ │ │██████│██████│ │ /█│██████│██████│█\ │ │██████│ │ /█│██████│█████/│ │ /█│█\ │\█████│██████│█\ │\█████│█████/│
|
|
2719
|
+
│ \███│██████│███\ │ 1 │██████│██████│ 2 │ /███│██████│██████│███\ │ . │██████│ 3 │ /███│██████│███/ │ . │ /███│███\ │ \███│██████│███\ │ \███│███/ │
|
|
2720
|
+
│ \█│██████│█████\│ │██████│██████│ │/█████│██████│██████│█████\│ │██████│ │/█████│██████│█/ │ │/█████│█████\│ \█│██████│█████\│ \█│█/ │
|
|
2721
|
+
├──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┤
|
|
2722
|
+
│██████│\█████│█████/│ │██████│██████│ │\█████│██████│██████│█████/│██████│ /█│█\ │\█████│█████/│ │██████│\█████│█████/│ │\█████│█████/│██████│ │
|
|
2723
|
+
│██████│ \███│███/ │ . │██████│██████│ . │ \███│██████│██████│███/ │██████│ /███│███\ │ \███│███/ │ 3 │██████│ \███│███/ │ 4 │ \███│███/ │██████│ . │
|
|
2724
|
+
│██████│ \█│█/ │ │██████│██████│ │ \█│██████│██████│█/ │██████│/█████│█████\│ \█│█/ │ │██████│ \█│█/ │ │ \█│█/ │██████│ │
|
|
2725
|
+
├──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┤
|
|
2726
|
+
│██████│ │ │ /█│█\ │ │██████│██████│\█████│█████/│ │ /█│██████│█████/│ │██████│ /█│█\ │ /█│█\ │ /█│█\ │ │ /█│█\ │
|
|
2727
|
+
│██████│ . │ 2 │ /███│███\ │ . │██████│██████│ \███│███/ │ 3 │ /███│██████│███/ │ 2 │██████│ /███│███\ │ /███│███\ │ /███│███\ │ 4 │ /███│███\ │
|
|
2728
|
+
│██████│ │ │/█████│█████\│ │██████│██████│ \█│█/ │ │/█████│██████│█/ │ │██████│/█████│█████\│/█████│█████\│/█████│█████\│ │/█████│█████\│
|
|
2729
|
+
├──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┤
|
|
2730
|
+
│ │██████│██████│\█████│█████/│ │██████│██████│ │██████│██████│\█████│█████/│██████│██████│ /█│██████│█████/│\█████│█████/│\█████│█████/│ /█│██████│█████/│
|
|
2731
|
+
│ . │██████│██████│ \███│███/ │ . │██████│██████│ 1 │██████│██████│ \███│███/ │██████│██████│ /███│██████│███/ │ \███│███/ │ \███│███/ │ /███│██████│███/ │
|
|
2732
|
+
│ │██████│██████│ \█│█/ │ │██████│██████│ │██████│██████│ \█│█/ │██████│██████│/█████│██████│█/ │ \█│█/ │ \█│█/ │/█████│██████│█/ │
|
|
2733
|
+
├──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┤
|
|
2734
|
+
│ │██████│██████│ │ /█│█\ │██████│██████│ │ /█│█\ │██████│ │ │ │\█████│█████/│ /█│█\ │ │██████│ /█│██████│█████/│ │
|
|
2735
|
+
│ 0 │██████│██████│ . │ /███│███\ │██████│██████│ . │ /███│███\ │██████│ . │ . │ . │ \███│███/ │ /███│███\ │ 3 │██████│ /███│██████│███/ │ . │
|
|
2736
|
+
│ │██████│██████│ │/█████│█████\│██████│██████│ │/█████│█████\│██████│ │ │ │ \█│█/ │/█████│█████\│ │██████│/█████│██████│█/ │ │
|
|
2737
|
+
├──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┤
|
|
2738
|
+
│ │██████│██████│ │\█████│██████│█\ │ │ /█│██████│█████/│ │██████│ /█│█\ │██████│ /█│██████│██████│█\ │██████│\█████│█████/│ │██████│
|
|
2739
|
+
│ 0 │██████│██████│ . │ \███│██████│███\ │ . │ /███│██████│███/ │ 1 │██████│ /███│███\ │██████│ /███│██████│██████│███\ │██████│ \███│███/ │ 3 │██████│
|
|
2740
|
+
│ │██████│██████│ │ \█│██████│█████\│ │/█████│██████│█/ │ │██████│/█████│█████\│██████│/█████│██████│██████│█████\│██████│ \█│█/ │ │██████│
|
|
2741
|
+
├──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┤
|
|
2742
|
+
│██████│ /█│█\ │ /█│█\ │\█████│██████│█\ │\█████│█████/│ │██████│ │\█████│█████/│ │\█████│██████│██████│██████│█\ │ │ /█│█\ │██████│
|
|
2743
|
+
│██████│ /███│███\ │ /███│███\ │ \███│██████│███\ │ \███│███/ │ 2 │██████│ . │ \███│███/ │ . │ \███│██████│██████│██████│███\ │ . │ /███│███\ │██████│
|
|
2744
|
+
│██████│/█████│█████\│/█████│█████\│ \█│██████│█████\│ \█│█/ │ │██████│ │ \█│█/ │ │ \█│██████│██████│██████│█████\│ │/█████│█████\│██████│
|
|
2745
|
+
├──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┤
|
|
2746
|
+
│ /█│██████│█████/│\█████│█████/│ │\█████│█████/│ │██████│ │██████│ │██████│ │ /█│█\ │\█████│██████│██████│█████/│██████│\█████│██████│█\ │
|
|
2747
|
+
│ /███│██████│███/ │ \███│███/ │ . │ \███│███/ │ . │██████│ . │██████│ . │██████│ . │ /███│███\ │ \███│██████│██████│███/ │██████│ \███│██████│███\ │
|
|
2748
|
+
│/█████│██████│█/ │ \█│█/ │ │ \█│█/ │ │██████│ │██████│ │██████│ │/█████│█████\│ \█│██████│██████│█/ │██████│ \█│██████│█████\│
|
|
2749
|
+
├──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┤
|
|
2750
|
+
│\█████│█████/│ /█│█\ │ │ /█│█\ │ │██████│ │██████│ /█│█\ │ /█│█\ │\█████│█████/│ │\█████│█████/│ │ /█│█\ │\█████│█████/│
|
|
2751
|
+
│ \███│███/ │ /███│███\ │ 4 │ /███│███\ │ 3 │██████│ . │██████│ /███│███\ │ /███│███\ │ \███│███/ │ . │ \███│███/ │ 4 │ /███│███\ │ \███│███/ │
|
|
2752
|
+
│ \█│█/ │/█████│█████\│ │/█████│█████\│ │██████│ │██████│/█████│█████\│/█████│█████\│ \█│█/ │ │ \█│█/ │ │/█████│█████\│ \█│█/ │
|
|
2753
|
+
├──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┤
|
|
2754
|
+
│██████│ │\█████│██████│█\ │\█████│█████/│ /█│█\ │██████│ │\█████│█████/│\█████│█████/│ │ /█│█\ │ │ /█│█\ │\█████│██████│█\ │ │
|
|
2755
|
+
│██████│ . │ \███│██████│███\ │ \███│███/ │ /███│███\ │██████│ . │ \███│███/ │ \███│███/ │ 3 │ /███│███\ │ . │ /███│███\ │ \███│██████│███\ │ 3 │
|
|
2756
|
+
│██████│ │ \█│██████│█████\│ \█│█/ │/█████│█████\│██████│ │ \█│█/ │ \█│█/ │ │/█████│█████\│ │/█████│█████\│ \█│██████│█████\│ │
|
|
2757
|
+
├──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┤
|
|
2758
|
+
│ │██████│██████│\█████│█████/│██████│██████│\█████│█████/│ │ /█│█\ │██████│ │██████│██████│\█████│██████│█\ │\█████│█████/│ │\█████│██████│█\ │
|
|
2759
|
+
│ . │██████│██████│ \███│███/ │██████│██████│ \███│███/ │ . │ /███│███\ │██████│ 1 │██████│██████│ \███│██████│███\ │ \███│███/ │ 4 │ \███│██████│███\ │
|
|
2760
|
+
│ │██████│██████│ \█│█/ │██████│██████│ \█│█/ │ │/█████│█████\│██████│ │██████│██████│ \█│██████│█████\│ \█│█/ │ │ \█│██████│█████\│
|
|
2761
|
+
├──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┤
|
|
2762
|
+
│ /█│█\ │ │██████│ │██████│██████│ │██████│ /█│██████│██████│█\ │ │██████│██████│ │\█████│█████/│ │ /█│█\ │██████│\█████│█████/│
|
|
2763
|
+
│ /███│███\ │ . │██████│ . │██████│██████│ 2 │██████│ /███│██████│██████│███\ │ . │██████│██████│ . │ \███│███/ │ . │ /███│███\ │██████│ \███│███/ │
|
|
2764
|
+
│/█████│█████\│ │██████│ │██████│██████│ │██████│/█████│██████│██████│█████\│ │██████│██████│ │ \█│█/ │ │/█████│█████\│██████│ \█│█/ │
|
|
2765
|
+
├──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┤
|
|
2766
|
+
│\█████│█████/│██████│ /█│█\ │██████│██████│ /█│█\ │\█████│██████│██████│██████│█\ │██████│██████│ │██████│ /█│█\ │\█████│█████/│ │ /█│█\ │
|
|
2767
|
+
│ \███│███/ │██████│ /███│███\ │██████│██████│ /███│███\ │ \███│██████│██████│██████│███\ │██████│██████│ 0 │██████│ /███│███\ │ \███│███/ │ . │ /███│███\ │
|
|
2768
|
+
│ \█│█/ │██████│/█████│█████\│██████│██████│/█████│█████\│ \█│██████│██████│██████│█████\│██████│██████│ │██████│/█████│█████\│ \█│█/ │ │/█████│█████\│
|
|
2769
|
+
├──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┤
|
|
2770
|
+
│ │██████│ /█│██████│█████/│██████│██████│\█████│█████/│ │\█████│██████│██████│█████/│██████│██████│ │ /█│██████│█████/│██████│██████│██████│\█████│█████/│
|
|
2771
|
+
│ . │██████│ /███│██████│███/ │██████│██████│ \███│███/ │ . │ \███│██████│██████│███/ │██████│██████│ . │ /███│██████│███/ │██████│██████│██████│ \███│███/ │
|
|
2772
|
+
│ │██████│/█████│██████│█/ │██████│██████│ \█│█/ │ │ \█│██████│██████│█/ │██████│██████│ │/█████│██████│█/ │██████│██████│██████│ \█│█/ │
|
|
2773
|
+
├──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┤
|
|
2774
|
+
│██████│ /█│██████│█████/│ /█│█\ │ │ │██████│██████│ │\█████│█████/│ /█│█\ │ │ /█│██████│█████/│██████│ │ /█│█\ │ /█│█\ │
|
|
2775
|
+
│██████│ /███│██████│███/ │ /███│███\ │ 2 │ . │██████│██████│ 2 │ \███│███/ │ /███│███\ │ . │ /███│██████│███/ │██████│ 1 │ /███│███\ │ /███│███\ │
|
|
2776
|
+
│██████│/█████│██████│█/ │/█████│█████\│ │ │██████│██████│ │ \█│█/ │/█████│█████\│ │/█████│██████│█/ │██████│ │/█████│█████\│/█████│█████\│
|
|
2777
|
+
├──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┤
|
|
2778
|
+
│ /█│██████│█████/│ │\█████│██████│█\ │ │██████│██████│ │ /█│█\ │\█████│█████/│██████│\█████│█████/│ │██████│ │\█████│█████/│\█████│█████/│
|
|
2779
|
+
│ /███│██████│███/ │ 3 │ \███│██████│███\ │ 2 │██████│██████│ 1 │ /███│███\ │ \███│███/ │██████│ \███│███/ │ . │██████│ . │ \███│███/ │ \███│███/ │
|
|
2780
|
+
│/█████│██████│█/ │ │ \█│██████│█████\│ │██████│██████│ │/█████│█████\│ \█│█/ │██████│ \█│█/ │ │██████│ │ \█│█/ │ \█│█/ │
|
|
2781
|
+
├──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┤
|
|
2782
|
+
│\█████│█████/│ │██████│██████│\█████│██████│█\ │██████│██████│ │\█████│██████│█\ │ │ /█│█\ │ │ /█│█\ │██████│██████│ /█│█\ │ │
|
|
2783
|
+
│ \███│███/ │ . │██████│██████│ \███│██████│███\ │██████│██████│ . │ \███│██████│███\ │ . │ /███│███\ │ . │ /███│███\ │██████│██████│ /███│███\ │ 2 │
|
|
2784
|
+
│ \█│█/ │ │██████│██████│ \█│██████│█████\│██████│██████│ │ \█│██████│█████\│ │/█████│█████\│ │/█████│█████\│██████│██████│/█████│█████\│ │
|
|
2785
|
+
├──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┤
|
|
2786
|
+
│ │ /█│█\ │ │ /█│█\ │\█████│██████│█\ │ /█│█\ │ │\█████│██████│█\ │\█████│█████/│██████│\█████│█████/│ │ /█│██████│█████/│██████│
|
|
2787
|
+
│ 2 │ /███│███\ │ . │ /███│███\ │ \███│██████│███\ │ /███│███\ │ 3 │ \███│██████│███\ │ \███│███/ │██████│ \███│███/ │ . │ /███│██████│███/ │██████│
|
|
2788
|
+
│ │/█████│█████\│ │/█████│█████\│ \█│██████│█████\│/█████│█████\│ │ \█│██████│█████\│ \█│█/ │██████│ \█│█/ │ │/█████│██████│█/ │██████│
|
|
2789
|
+
├──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┤
|
|
2790
|
+
│██████│\█████│█████/│██████│\█████│█████/│ │\█████│█████/│\█████│█████/│██████│ │\█████│█████/│██████│██████│ │██████│██████│██████│\█████│█████/│ │██████│
|
|
2791
|
+
│██████│ \███│███/ │██████│ \███│███/ │ 3 │ \███│███/ │ \███│███/ │██████│ 2 │ \███│███/ │██████│██████│ 0 │██████│██████│██████│ \███│███/ │ 2 │██████│
|
|
2792
|
+
│██████│ \█│█/ │██████│ \█│█/ │ │ \█│█/ │ \█│█/ │██████│ │ \█│█/ │██████│██████│ │██████│██████│██████│ \█│█/ │ │██████│
|
|
2793
|
+
└──────┴──────┴──────┴──────┴──────┴──────┴──────┴──────┴──────┴──────┴──────┴──────┴──────┴──────┴──────┴──────┴──────┴──────┴──────┴──────┴──────┴──────┴──────┴──────┴──────┘
|
|
2794
|
+
Solutions found: 1
|
|
2795
|
+
status: OPTIMAL
|
|
2796
|
+
Time taken: 0.36 seconds
|
|
2797
|
+
```
|
|
2798
|
+
|
|
2799
|
+
**Solved puzzle**
|
|
2800
|
+
|
|
2801
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/shakashaka_solved.png" alt="Shakashaka solved" width="500">
|
|
2802
|
+
|
|
2803
|
+
---
|
|
2804
|
+
|
|
2805
|
+
## Sudoku Killer (Puzzle Type #53)
|
|
2806
|
+
|
|
2807
|
+
* [**Play online**](https://www.puzzle-killer-sudoku.com/)
|
|
2808
|
+
|
|
2809
|
+
* [**Solver Code**](https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/sudoku)
|
|
2810
|
+
|
|
2811
|
+
<details>
|
|
2812
|
+
<summary><strong>Rules</strong></summary>
|
|
2813
|
+
|
|
2814
|
+
1. The basic Sudoku rules apply.
|
|
2815
|
+
2. The sum of all numbers in a cage must match the small number printed in its corner.
|
|
2816
|
+
3. No number appears more than once in a cage.
|
|
2817
|
+
|
|
2818
|
+
</details>
|
|
2819
|
+
|
|
2820
|
+
**Unsolved puzzle**
|
|
2821
|
+
|
|
2822
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/sudoku_killer_unsolved.png" alt="Sudoku Killer unsolved" width="500">
|
|
2823
|
+
|
|
2824
|
+
Code to utilize this package and solve the puzzle:
|
|
2825
|
+
|
|
2826
|
+
(Note: the ids are arbitrary and simply represent cells that share a cage)
|
|
2827
|
+
|
|
2828
|
+
```python
|
|
2829
|
+
import numpy as np
|
|
2830
|
+
from puzzle_solver import sudoku_solver as solver
|
|
2831
|
+
board = np.full((9, 9), ' ')
|
|
2832
|
+
killer_board = np.array([
|
|
2833
|
+
['01', '01', '03', '03', '03', '12', '12', '13', '14'],
|
|
2834
|
+
['02', '01', '04', '16', '16', '17', '17', '13', '14'],
|
|
2835
|
+
['02', '02', '04', '18', '19', '19', '15', '15', '14'],
|
|
2836
|
+
['11', '11', '05', '18', '19', '19', '20', '15', '23'],
|
|
2837
|
+
['10', '10', '05', '30', '31', '32', '20', '22', '23'],
|
|
2838
|
+
['08', '07', '06', '30', '31', '32', '21', '22', '24'],
|
|
2839
|
+
['08', '07', '06', '29', '31', '33', '21', '24', '24'],
|
|
2840
|
+
['09', '34', '34', '29', '28', '33', '26', '26', '25'],
|
|
2841
|
+
['09', '34', '34', '28', '28', '27', '27', '25', '25'],
|
|
2842
|
+
])
|
|
2843
|
+
killer_clues = {
|
|
2844
|
+
'01': 16, '02': 11, '03': 24, '04': 10, '05': 11, '06': 7, '07': 10, '08': 10, '09': 16,
|
|
2845
|
+
'10': 11, '11': 10, '12': 7, '13': 11, '14': 16, '15': 16, '16': 8, '17': 12, '18': 8, '19': 15,
|
|
2846
|
+
'20': 7, '21': 10, '22': 5, '23': 13, '24': 16, '25': 9, '26': 14, '27': 15, '28': 13, '29': 11,
|
|
2847
|
+
'30': 9, '31': 15, '32': 13, '33': 11, '34': 15,
|
|
2848
|
+
}
|
|
2849
|
+
binst = solver.Board(board=board, block_size=(3, 3), killer=(killer_board, killer_clues))
|
|
2850
|
+
solutions = binst.solve_and_print()
|
|
2851
|
+
```
|
|
2852
|
+
|
|
2853
|
+
**Script Output**
|
|
2854
|
+
|
|
2855
|
+
```python
|
|
2856
|
+
Solution found
|
|
2857
|
+
|
|
2858
|
+
0 1 2 3 4 5 6 7 8
|
|
2859
|
+
┌───┬───┬───┬───┬───┬───┬───┬───┬───┐
|
|
2860
|
+
0│ 5 │ 4 │ 8 │ 7 │ 9 │ 1 │ 6 │ 2 │ 3 │
|
|
2861
|
+
├───┼───┼───┼───┼───┼───┼───┼───┼───┤
|
|
2862
|
+
1│ 3 │ 7 │ 1 │ 6 │ 2 │ 8 │ 4 │ 9 │ 5 │
|
|
2863
|
+
├───┼───┼───┼───┼───┼───┼───┼───┼───┤
|
|
2864
|
+
2│ 2 │ 6 │ 9 │ 5 │ 4 │ 3 │ 1 │ 7 │ 8 │
|
|
2865
|
+
├───┼───┼───┼───┼───┼───┼───┼───┼───┤
|
|
2866
|
+
3│ 1 │ 9 │ 4 │ 3 │ 6 │ 2 │ 5 │ 8 │ 7 │
|
|
2867
|
+
├───┼───┼───┼───┼───┼───┼───┼───┼───┤
|
|
2868
|
+
4│ 8 │ 3 │ 7 │ 1 │ 5 │ 9 │ 2 │ 4 │ 6 │
|
|
2869
|
+
├───┼───┼───┼───┼───┼───┼───┼───┼───┤
|
|
2870
|
+
5│ 6 │ 2 │ 5 │ 8 │ 7 │ 4 │ 3 │ 1 │ 9 │
|
|
2871
|
+
├───┼───┼───┼───┼───┼───┼───┼───┼───┤
|
|
2872
|
+
6│ 4 │ 8 │ 2 │ 9 │ 3 │ 5 │ 7 │ 6 │ 1 │
|
|
2873
|
+
├───┼───┼───┼───┼───┼───┼───┼───┼───┤
|
|
2874
|
+
7│ 7 │ 1 │ 3 │ 2 │ 8 │ 6 │ 9 │ 5 │ 4 │
|
|
2875
|
+
├───┼───┼───┼───┼───┼───┼───┼───┼───┤
|
|
2876
|
+
8│ 9 │ 5 │ 6 │ 4 │ 1 │ 7 │ 8 │ 3 │ 2 │
|
|
2877
|
+
└───┴───┴───┴───┴───┴───┴───┴───┴───┘
|
|
2878
|
+
Solutions found: 1
|
|
2879
|
+
status: OPTIMAL
|
|
2880
|
+
Time taken: 0.02 seconds
|
|
2881
|
+
```
|
|
2882
|
+
|
|
2883
|
+
**Solved puzzle**
|
|
2884
|
+
|
|
2885
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/sudoku_killer_solved.png" alt="Sudoku Killer solved" width="500">
|
|
2886
|
+
|
|
2887
|
+
---
|
|
2888
|
+
|
|
2889
|
+
## Flood It (Puzzle Type #54)
|
|
2890
|
+
|
|
2891
|
+
* [**Play online**](https://www.chiark.greenend.org.uk/~sgtatham/puzzles/js/flood.html)
|
|
2892
|
+
|
|
2893
|
+
* [**Instructions**](https://www.chiark.greenend.org.uk/~sgtatham/puzzles/doc/flood.html#flood)
|
|
2894
|
+
|
|
2895
|
+
* [**Solver Code**](https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/flood_it)
|
|
2896
|
+
|
|
2897
|
+
<details>
|
|
2898
|
+
<summary><strong>Rules</strong></summary>
|
|
2899
|
+
|
|
2900
|
+
The game is a combinatorial puzzle played on a colored N by N grid where the goal is to make the entire grid a single color using the minimum number of moves.
|
|
2901
|
+
|
|
2902
|
+
A move consists of picking a new color, which then floods the connected component of the player's current area that has that chosen color.
|
|
2903
|
+
|
|
2904
|
+
The player's current area is the top-leftmost corner of the grid along with any similarly colored orthogonal cells connected to the current area.
|
|
2905
|
+
|
|
2906
|
+
</details>
|
|
2907
|
+
|
|
2908
|
+
This game has a lot of interesting mathematical properties related to Graph Theory (for example many details are referenced in this [2022 Graph Theory paper](https://arxiv.org/pdf/1101.5876))
|
|
2909
|
+
|
|
2910
|
+
Finding an optimal solution for any graph is NP-hard.
|
|
2911
|
+
|
|
2912
|
+
**Unsolved puzzle**
|
|
2913
|
+
|
|
2914
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/flood_it_unsolved.png" alt="Flood It unsolved" width="500">
|
|
2915
|
+
|
|
2916
|
+
Code to utilize this package and solve the puzzle:
|
|
2917
|
+
|
|
2918
|
+
(Note: the ids are arbitrary and simply represent cells that share a cage)
|
|
2919
|
+
|
|
2920
|
+
```python
|
|
2921
|
+
import numpy as np
|
|
2922
|
+
from puzzle_solver import flood_it_solver as solver
|
|
2923
|
+
board = np.array([
|
|
2924
|
+
['B', 'Y', 'G', 'Y', 'R', 'B', 'Y', 'Y', 'G', 'B', 'R', 'P'],
|
|
2925
|
+
['P', 'G', 'G', 'Y', 'B', 'O', 'Y', 'O', 'B', 'Y', 'R', 'O'],
|
|
2926
|
+
['B', 'R', 'P', 'Y', 'O', 'R', 'G', 'G', 'G', 'R', 'R', 'Y'],
|
|
2927
|
+
['O', 'G', 'P', 'G', 'Y', 'Y', 'P', 'P', 'O', 'Y', 'B', 'B'],
|
|
2928
|
+
['G', 'Y', 'G', 'O', 'R', 'G', 'R', 'P', 'G', 'O', 'B', 'R'],
|
|
2929
|
+
['R', 'G', 'B', 'G', 'O', 'B', 'O', 'G', 'B', 'O', 'O', 'B'],
|
|
2930
|
+
['G', 'B', 'P', 'R', 'Y', 'P', 'R', 'B', 'Y', 'B', 'Y', 'P'],
|
|
2931
|
+
['G', 'B', 'G', 'P', 'O', 'Y', 'R', 'Y', 'P', 'P', 'O', 'G'],
|
|
2932
|
+
['R', 'P', 'B', 'O', 'B', 'G', 'Y', 'O', 'Y', 'R', 'P', 'O'],
|
|
2933
|
+
['G', 'P', 'P', 'P', 'P', 'Y', 'G', 'P', 'O', 'G', 'O', 'R'],
|
|
2934
|
+
['Y', 'Y', 'B', 'B', 'R', 'B', 'O', 'R', 'O', 'O', 'R', 'O'],
|
|
2935
|
+
['B', 'G', 'B', 'G', 'R', 'B', 'P', 'Y', 'P', 'B', 'R', 'G']
|
|
2936
|
+
])
|
|
2937
|
+
solution = solver.solve_minimum_steps(board=board)
|
|
2938
|
+
```
|
|
2939
|
+
|
|
2940
|
+
**Script Output**
|
|
2941
|
+
|
|
2942
|
+
```python
|
|
2943
|
+
Trying with exactly 16 moves... Not possible!
|
|
2944
|
+
Trying with exactly 32 moves... Possible!
|
|
2945
|
+
Solution: ['Y', 'G', 'B', 'Y', 'B', 'R', 'B', 'Y', 'G', 'Y', 'G', 'B', 'B', 'G', 'Y', 'Y', 'R', 'B', 'Y', 'G', 'Y', 'B', 'Y', 'B', 'Y', 'B', 'G', 'Y', 'B', 'G', 'R', 'Y']
|
|
2946
|
+
Trying with exactly 24 moves... Possible!
|
|
2947
|
+
Solution: ['Y', 'G', 'B', 'Y', 'B', 'R', 'B', 'R', 'Y', 'G', 'R', 'Y', 'R', 'B', 'G', 'B', 'G', 'Y', 'G', 'B', 'Y', 'G', 'R', 'Y']
|
|
2948
|
+
Trying with exactly 20 moves... Possible!
|
|
2949
|
+
Solution: ['Y', 'G', 'B', 'Y', 'B', 'R', 'B', 'G', 'Y', 'G', 'B', 'G', 'Y', 'B', 'Y', 'R', 'B', 'G', 'R', 'Y']
|
|
2950
|
+
Trying with exactly 18 moves... Possible!
|
|
2951
|
+
Solution: ['Y', 'G', 'B', 'Y', 'R', 'B', 'R', 'Y', 'B', 'G', 'R', 'Y', 'R', 'B', 'G', 'R', 'Y', 'B']
|
|
2952
|
+
Trying with exactly 17 moves... Not possible!
|
|
2953
|
+
Best Horizon is: T=18
|
|
2954
|
+
Best solution is: ['Y', 'G', 'B', 'Y', 'R', 'B', 'R', 'Y', 'B', 'G', 'R', 'Y', 'R', 'B', 'G', 'R', 'Y', 'B']
|
|
2955
|
+
Time taken: 3.10 seconds
|
|
2956
|
+
```
|
|
2957
|
+
|
|
2958
|
+
**Solved puzzle**
|
|
2959
|
+
|
|
2960
|
+
This picture won't mean much as the game is about the sequence and number of moves not the final frame as shown here.
|
|
2961
|
+
|
|
2962
|
+
Note that the solved solution on the bottom left says that only 18 moves were used (based on the above output) despite the website saying 20 total moves are permitted (and the puzzle settings specified 0 extra moves permitted). Thus the solver managed to find a more optimal solution than the website.
|
|
2963
|
+
|
|
2964
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/flood_it_solved.png" alt="Flood It solved" width="500">
|
|
2965
|
+
|
|
2966
|
+
---
|
|
2967
|
+
|
|
2968
|
+
## Pipes (Puzzle Type #55)
|
|
2969
|
+
|
|
2970
|
+
Also known as Net or Network.
|
|
2971
|
+
|
|
2972
|
+
* [**Play online 1**](https://www.chiark.greenend.org.uk/~sgtatham/puzzles/js/net.html)
|
|
2973
|
+
|
|
2974
|
+
* [**Play online 2**](https://www.puzzle-pipes.com/)
|
|
2975
|
+
|
|
2976
|
+
* [**Instructions**](https://www.chiark.greenend.org.uk/~sgtatham/puzzles/doc/net.html#net)
|
|
2977
|
+
|
|
2978
|
+
* [**Solver Code**](https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/pipes)
|
|
2979
|
+
|
|
2980
|
+
<details>
|
|
2981
|
+
<summary><strong>Rules</strong></summary>
|
|
2982
|
+
|
|
2983
|
+
You are given a grid of cells where each cell has 1, 2, 3, or 4 connections to its neighbors. Each cell can be freely rotated in multiple of 90 degrees, thus your can rotate the cells to be one of four possible states.
|
|
2984
|
+
|
|
2985
|
+
The goal is to create a single fully connected graph where each cell's connection must be towards another cell's connection. No loose ends or loops are allowed.
|
|
2986
|
+
|
|
2987
|
+
</details>
|
|
2988
|
+
|
|
2989
|
+
**Unsolved puzzle**
|
|
2990
|
+
|
|
2991
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/pipes_unsolved.png" alt="Pipes unsolved" width="500">
|
|
2992
|
+
|
|
2993
|
+
Code to utilize this package and solve the puzzle:
|
|
2994
|
+
|
|
2995
|
+
(Note: cells with 1 or 3 active connections only have 1 unique orientation under rotational symmetry. However, cells with 2 active connections can be either a straight line (2I) or curved line (2L))
|
|
2996
|
+
|
|
2997
|
+
```python
|
|
2998
|
+
import numpy as np
|
|
2999
|
+
from puzzle_solver import pipes_solver as solver
|
|
3000
|
+
board=np.array([
|
|
3001
|
+
[ '1 ', '3 ', '3 ', '3 ', '1 ', '1 ', '2L', '2L', '2I', '1 ' ],
|
|
3002
|
+
[ '1 ', '1 ', '1 ', '3 ', '2I', '1 ', '2I', '3 ', '2I', '1 ' ],
|
|
3003
|
+
[ '2I', '1 ', '1 ', '3 ', '2L', '1 ', '3 ', '2I', '1 ', '1 ' ],
|
|
3004
|
+
[ '2I', '2I', '1 ', '3 ', '3 ', '3 ', '2L', '3 ', '3 ', '2L' ],
|
|
3005
|
+
[ '3 ', '3 ', '2I', '3 ', '1 ', '3 ', '2I', '2L', '1 ', '2L' ],
|
|
3006
|
+
[ '1 ', '1 ', '3 ', '2I', '3 ', '2L', '1 ', '1 ', '2L', '2L' ],
|
|
3007
|
+
[ '1 ', '1 ', '3 ', '1 ', '1 ', '1 ', '3 ', '3 ', '3 ', '2L' ],
|
|
3008
|
+
[ '3 ', '2I', '3 ', '3 ', '2L', '3 ', '3 ', '2I', '2L', '1 ' ],
|
|
3009
|
+
[ '1 ', '1 ', '3 ', '3 ', '3 ', '3 ', '1 ', '2L', '3 ', '2L' ],
|
|
3010
|
+
[ '1 ', '2I', '3 ', '2I', '1 ', '1 ', '1 ', '3 ', '1 ', '1 ' ],
|
|
3011
|
+
])
|
|
3012
|
+
binst = solver.Board(board=board)
|
|
3013
|
+
solutions = binst.solve_and_print()
|
|
3014
|
+
```
|
|
3015
|
+
|
|
3016
|
+
**Script Output**
|
|
3017
|
+
|
|
3018
|
+
```python
|
|
3019
|
+
Solution found
|
|
3020
|
+
0 0 0 0 0 0 0 0 0 0
|
|
3021
|
+
0 1 2 3 4 5 6 7 8 9
|
|
3022
|
+
|
|
3023
|
+
0 O───┬───┬───┬───O O───┐ ┌───────O
|
|
3024
|
+
│ │ │ │ │
|
|
3025
|
+
1 O O O ├───────O │ ├───────O
|
|
3026
|
+
│ │ │ │
|
|
3027
|
+
2 │ O O───┴───┐ O───┤ │ O O
|
|
3028
|
+
│ │ │ │ │ │ │
|
|
3029
|
+
3 │ │ O───┬───┴───┬───┘ ├───┴───┘
|
|
3030
|
+
│ │ │ │ │
|
|
3031
|
+
4 ├───┴───────┴───O ├───────┘ O───┐
|
|
3032
|
+
│ │ │
|
|
3033
|
+
5 O O───┬───────┬───┘ O O ┌───┘
|
|
3034
|
+
│ │ │ │ │
|
|
3035
|
+
6 O O───┤ O O O ├───┴───┴───┐
|
|
3036
|
+
│ │ │ │ │ │
|
|
3037
|
+
7 ├───────┴───┤ ┌───┴───┴───────┐ O
|
|
3038
|
+
│ │ │ │
|
|
3039
|
+
8 O O───┬───┴───┴───┬───O ┌───┴───┐
|
|
3040
|
+
│ │ │ │
|
|
3041
|
+
9 O───────┴───────O O O───┴───O O
|
|
3042
|
+
|
|
3043
|
+
Solutions found: 1
|
|
3044
|
+
status: OPTIMAL
|
|
3045
|
+
Time taken: 5.65 seconds
|
|
3046
|
+
```
|
|
3047
|
+
|
|
3048
|
+
**Solved puzzle**
|
|
3049
|
+
|
|
3050
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/pipes_solved.png" alt="Pipes solved" width="500">
|
|
3051
|
+
|
|
3052
|
+
---
|
|
3053
|
+
|
|
3054
|
+
## Connect the Dots (Puzzle Type #56)
|
|
3055
|
+
|
|
3056
|
+
Also known as Numberlink.
|
|
3057
|
+
|
|
3058
|
+
* [**Mobile App (Android)**](https://play.google.com/store/apps/details?id=com.playvalve.connect.dots&hl=en_US)
|
|
3059
|
+
|
|
3060
|
+
* [**Mobile App (iOS)**](https://apps.apple.com/us/app/dot-link-connect-the-dots/id6444312485)
|
|
3061
|
+
|
|
3062
|
+
* [**Solver Code**](https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/connect_the_dots)
|
|
3063
|
+
|
|
3064
|
+
<details>
|
|
3065
|
+
<summary><strong>Rules</strong></summary>
|
|
3066
|
+
|
|
3067
|
+
You are given a grid of empty cells and 2 filled cell per color. The goal is to connect the dots of the same color to form a single fully connected graph for each color.
|
|
3068
|
+
|
|
3069
|
+
</details>
|
|
3070
|
+
|
|
3071
|
+
**Unsolved puzzle**
|
|
3072
|
+
|
|
3073
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/connect_the_dots_unsolved.png" alt="Connect the Dots unsolved" width="500">
|
|
3074
|
+
|
|
3075
|
+
Code to utilize this package and solve the puzzle:
|
|
3076
|
+
|
|
3077
|
+
```python
|
|
3078
|
+
import numpy as np
|
|
3079
|
+
from puzzle_solver import connect_the_dots_solver as solver
|
|
3080
|
+
board = np.array([
|
|
3081
|
+
['R', ' ', 'B', ' ', ' ', ' ', ' ', ' '],
|
|
3082
|
+
['Y', ' ', ' ', 'R', 'G', ' ', 'G', ' '],
|
|
3083
|
+
[' ', 'M', ' ', ' ', ' ', 'P', ' ', ' '],
|
|
3084
|
+
[' ', 'O', ' ', ' ', ' ', 'M', ' ', ' '],
|
|
3085
|
+
[' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '],
|
|
3086
|
+
['Br', 'B', ' ', ' ', 'Y', 'O', ' ', ' '],
|
|
3087
|
+
[' ', ' ', ' ', ' ', ' ', 'P', ' ', ' '],
|
|
3088
|
+
[' ', ' ', ' ', 'Br', ' ', ' ', ' ', ' '],
|
|
3089
|
+
])
|
|
3090
|
+
binst = solver.Board(board=board)
|
|
3091
|
+
solutions = binst.solve_and_print()
|
|
3092
|
+
```
|
|
3093
|
+
|
|
3094
|
+
**Script Output**
|
|
3095
|
+
|
|
3096
|
+
```python
|
|
3097
|
+
Solution found
|
|
3098
|
+
|
|
3099
|
+
0 1 2 3 4 5 6 7
|
|
3100
|
+
┌───────┬───────────────────────┐
|
|
3101
|
+
0│ R R │ B B B B B B │
|
|
3102
|
+
├───┐ └───────┬───────────┐ │
|
|
3103
|
+
1│ Y │ R R R │ G G G │ B │
|
|
3104
|
+
│ ├───────────┴───┬───────┤ │
|
|
3105
|
+
2│ Y │ M M M M │ P P │ B │
|
|
3106
|
+
│ ├───────────┐ └───┐ │ │
|
|
3107
|
+
3│ Y │ O O O │ M M │ P │ B │
|
|
3108
|
+
│ └───────┐ └───────┤ │ │
|
|
3109
|
+
4│ Y Y Y │ O O O │ P │ B │
|
|
3110
|
+
├───┬───┐ └───────┐ │ │ │
|
|
3111
|
+
5│Br │ B │ Y Y Y │ O │ P │ B │
|
|
3112
|
+
│ │ └───────────┼───┘ │ │
|
|
3113
|
+
6│Br │ B B B B │ P P │ B │
|
|
3114
|
+
│ └───────────┐ └───────┘ │
|
|
3115
|
+
7│Br Br Br Br │ B B B B │
|
|
3116
|
+
└───────────────┴───────────────┘
|
|
3117
|
+
Solutions found: 1
|
|
3118
|
+
status: OPTIMAL
|
|
3119
|
+
Time taken: 0.07 seconds
|
|
3120
|
+
```
|
|
3121
|
+
|
|
3122
|
+
**Solved puzzle**
|
|
3123
|
+
|
|
3124
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/connect_the_dots_solved.png" alt="Connect the Dots solved" width="500">
|
|
3125
|
+
|
|
3126
|
+
---
|
|
3127
|
+
|
|
3128
|
+
## Nonograms Colored (Puzzle Type #57)
|
|
3129
|
+
|
|
3130
|
+
Also known as Nonogrids, Numbergrids, Picross, Hanjie, Paint by Numbers, Griddlers, or Pic-a-Pix.
|
|
3131
|
+
|
|
3132
|
+
* [**Play online**](https://www.nonograms.org/nonograms2)
|
|
3133
|
+
|
|
3134
|
+
* [**Solver Code**](https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/nonograms)
|
|
3135
|
+
|
|
3136
|
+
<details>
|
|
3137
|
+
<summary><strong>Rules</strong></summary>
|
|
3138
|
+
|
|
3139
|
+
You have a grid of squares, which must all be filled in either white or one of the specified colors. Beside each row of the grid are listed, in order, the lengths of the runs of the specified colors on that row; above each column are listed, in order, the lengths of the runs of the specified colors in that column. Your aim is to fill in the entire grid white or one of the specified colors.
|
|
3140
|
+
|
|
3141
|
+
</details>
|
|
3142
|
+
|
|
3143
|
+
**Unsolved puzzle**
|
|
3144
|
+
|
|
3145
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/nonograms_colored_unsolved.png" alt="Nonograms Colored unsolved" width="500">
|
|
3146
|
+
|
|
3147
|
+
Code to utilize this package and solve the puzzle:
|
|
3148
|
+
|
|
3149
|
+
```python
|
|
3150
|
+
import numpy as np
|
|
3151
|
+
from puzzle_solver.puzzles.nonograms import nonograms_colored as solver
|
|
3152
|
+
top = [
|
|
3153
|
+
['5M'], ['8M'], ['1M', '3R', '6M'], ['1M', '5R', '5M'], ['8R', '4M'],
|
|
3154
|
+
['10R', '4M'], ['10R', '4M'], ['1G', '2M', '2R', '3P', '7R', '3M'], ['1L', '2G', '1G', '2F', '3M', '1R', '5P', '6R', '3M'], ['2L', '2G', '2F', '4M', '1R', '6P', '5R', '3M'],
|
|
3155
|
+
['3L', '1F', '1R', '2M', '8P', '5R', '3M'], ['1G', '1L', '1F', '1R', '2M', '8P', '5R', '3M'], ['1G', '2L', '2R', '1M', '8P', '5R', '3M'], ['1L', '1G', '3R', '1M', '8P', '5R', '3M'], ['1L', '3R', '2M', '7P', '6R', '3M'],
|
|
3156
|
+
['1L', '3R', '1M', '8P', '5R', '4M'], ['1L', '3R', '1M', '8P', '5R', '4M'], ['2R', '1M', '9P', '5R', '3M'], ['1R', '9P', '5R', '3M'], ['10P', '5R', '3M'],
|
|
3157
|
+
['1G', '1R', '9P', '5R', '4M'], ['1L', '1G', '1F', '2R', '8P', '5R', '6M'], ['1L', '2F', '3R', '6P', '5R', '7M'], ['1L', '1G', '1F', '4R', '5P', '5R', '3M', '3P', '2M'], ['1L', '1F', '6R', '2P', '6R', '3M', '4P', '2M'],
|
|
3158
|
+
['1L', '1F', '12R', '4M', '6P', '1M'], ['1L', '1F', '1R', '3L', '1M', '3R', '7M', '7P', '1M'], ['1G', '3L', '1G', '11M', '7P', '1R', '1M'], ['1L', '1L', '3G', '11M', '1R', '6P', '2R'], ['1G', '3L', '1G', '4F', '6M', '9R'],
|
|
3159
|
+
['3G', '2F', '2L', '1F', '4M', '7R'], ['4G', '1F', '4L'], ['1L', '1G', '1F', '1L', '2L'], ['2F', '1L']
|
|
3160
|
+
]
|
|
3161
|
+
side = [
|
|
3162
|
+
['1L', '1G'], ['1L', '1G'], ['1L', '2G'], ['6L', '1G', '2L', '2G'], ['2L', '1G', '3F', '1L', '2G', '1F', '1G'],
|
|
3163
|
+
['1G', '1L', '1G', '2F', '3R', '1L', '1G', '2F', '1G', '1L'], ['2G', '1L', '1G', '2F', '3R', '2L', '1G', '1F', '1L', '1F', '1G'], ['1G', '1L', '2G', '4L', '5R', '1L', '1G', '1M', '1F', '2L', '1F'], ['1G', '1F', '3L', '1G', '4R', '6R', '1L', '2M', '2F', '2L', '1F'], ['4F', '1L', '6R', '3P', '4R', '5M', '1L', '1F'],
|
|
3164
|
+
['1G', '1F', '1M', '7R', '1M', '6P', '3R', '4M', '2L'], ['5M', '2R', '3M', '8P', '2R', '4M', '2L'], ['8M', '10P', '2R', '4M'], ['2M', '14P', '2R', '4M'], ['3R', '14P', '2R', '4M'],
|
|
3165
|
+
['3R', '15P', '3R', '3M'], ['3R', '15P', '4R', '3M'], ['1M', '3R', '14P', '4R', '4M'], ['1M', '4R', '13P', '5R', '3M', '2R'], ['1M', '6R', '10P', '6R', '3M', '2P', '2R'],
|
|
3166
|
+
['1M', '7R', '5P', '9R', '3M', '3P', '2R'], ['2M', '20R', '3M', '4P', '2R'], ['3M', '18R', '3M', '5P', '2R'], ['4M', '16R', '3M', '6P', '2R'], ['5M', '13R', '5M', '6P', '2R'],
|
|
3167
|
+
['7M', '8R', '8M', '5P', '3R'], ['24M', '2P', '3R'], ['16M', '7M'], ['12M']
|
|
3168
|
+
]
|
|
3169
|
+
binst = solver.Board(top=top, side=side)
|
|
3170
|
+
solutions = binst.solve_and_print(visualize_colors={
|
|
3171
|
+
'M': 'darkmagenta',
|
|
3172
|
+
'R': 'magenta',
|
|
3173
|
+
'G': 'green',
|
|
3174
|
+
'P': 'pink',
|
|
3175
|
+
'L': 'lime',
|
|
3176
|
+
'F': 'forestgreen',
|
|
3177
|
+
})
|
|
3178
|
+
```
|
|
3179
|
+
|
|
3180
|
+
**Script Output**
|
|
3181
|
+
|
|
3182
|
+
```python
|
|
3183
|
+
Solution found
|
|
3184
|
+
0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 3 3 3 3
|
|
3185
|
+
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3
|
|
3186
|
+
┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┐
|
|
3187
|
+
0│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ L │ G │ │ │ │ │
|
|
3188
|
+
├───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┤
|
|
3189
|
+
1│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ L │ G │ │ │ │
|
|
3190
|
+
├───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┤
|
|
3191
|
+
2│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ L │ G │ G │ │ │
|
|
3192
|
+
├───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┤
|
|
3193
|
+
3│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ L │ L │ L │ L │ L │ L │ G │ L │ L │ G │ G │ │ │
|
|
3194
|
+
├───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┤
|
|
3195
|
+
4│ │ │ │ │ │ │ │ │ L │ L │ │ │ │ │ │ │ │ │ │ │ │ │ │ G │ F │ F │ F │ L │ G │ G │ F │ G │ │ │
|
|
3196
|
+
├───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┤
|
|
3197
|
+
5│ │ │ │ │ │ │ │ │ G │ L │ │ │ │ │ │ │ │ │ │ │ │ G │ F │ F │ R │ R │ R │ L │ G │ F │ F │ G │ L │ │
|
|
3198
|
+
├───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┤
|
|
3199
|
+
6│ │ │ │ │ │ │ │ │ G │ G │ L │ │ │ │ │ │ │ │ │ │ G │ F │ F │ R │ R │ R │ L │ L │ G │ F │ L │ F │ G │ │
|
|
3200
|
+
├───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┤
|
|
3201
|
+
7│ │ │ │ │ │ │ │ │ │ G │ L │ G │ G │ L │ L │ L │ L │ │ │ │ │ R │ R │ R │ R │ R │ L │ G │ M │ F │ L │ L │ F │ │
|
|
3202
|
+
├───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┤
|
|
3203
|
+
8│ │ │ │ │ │ │ │ │ G │ F │ L │ L │ L │ G │ R │ R │ R │ R │ │ │ R │ R │ R │ R │ R │ R │ L │ M │ M │ F │ F │ L │ L │ F │
|
|
3204
|
+
├───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┤
|
|
3205
|
+
9│ │ │ │ │ │ │ │ │ F │ F │ F │ F │ L │ R │ R │ R │ R │ R │ R │ P │ P │ P │ R │ R │ R │ R │ M │ M │ M │ M │ M │ L │ │ F │
|
|
3206
|
+
├───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┤
|
|
3207
|
+
10│ │ │ │ │ │ │ │ G │ F │ M │ R │ R │ R │ R │ R │ R │ R │ M │ P │ P │ P │ P │ P │ P │ R │ R │ R │ M │ M │ M │ M │ L │ L │ │
|
|
3208
|
+
├───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┤
|
|
3209
|
+
11│ │ │ │ │ │ │ │ M │ M │ M │ M │ M │ R │ R │ M │ M │ M │ P │ P │ P │ P │ P │ P │ P │ P │ R │ R │ M │ M │ M │ M │ │ L │ L │
|
|
3210
|
+
├───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┤
|
|
3211
|
+
12│ │ │ │ │ │ │ │ M │ M │ M │ M │ M │ M │ M │ M │ P │ P │ P │ P │ P │ P │ P │ P │ P │ P │ R │ R │ M │ M │ M │ M │ │ │ │
|
|
3212
|
+
├───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┤
|
|
3213
|
+
13│ │ │ │ │ │ │ │ │ M │ M │ P │ P │ P │ P │ P │ P │ P │ P │ P │ P │ P │ P │ P │ P │ R │ R │ M │ M │ M │ M │ │ │ │ │
|
|
3214
|
+
├───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┤
|
|
3215
|
+
14│ │ │ │ │ │ │ │ R │ R │ R │ P │ P │ P │ P │ P │ P │ P │ P │ P │ P │ P │ P │ P │ P │ R │ R │ M │ M │ M │ M │ │ │ │ │
|
|
3216
|
+
├───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┤
|
|
3217
|
+
15│ │ │ │ │ │ R │ R │ R │ P │ P │ P │ P │ P │ P │ P │ P │ P │ P │ P │ P │ P │ P │ P │ R │ R │ R │ M │ M │ M │ │ │ │ │ │
|
|
3218
|
+
├───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┤
|
|
3219
|
+
16│ │ │ │ │ R │ R │ R │ P │ P │ P │ P │ P │ P │ P │ P │ P │ P │ P │ P │ P │ P │ P │ R │ R │ R │ R │ M │ M │ M │ │ │ │ │ │
|
|
3220
|
+
├───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┤
|
|
3221
|
+
17│ │ │ │ M │ R │ R │ R │ P │ P │ P │ P │ P │ P │ P │ P │ P │ P │ P │ P │ P │ P │ R │ R │ R │ R │ M │ M │ M │ M │ │ │ │ │ │
|
|
3222
|
+
├───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┤
|
|
3223
|
+
18│ │ │ M │ R │ R │ R │ R │ P │ P │ P │ P │ P │ P │ P │ P │ P │ P │ P │ P │ P │ R │ R │ R │ R │ R │ M │ M │ M │ R │ R │ │ │ │ │
|
|
3224
|
+
├───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┤
|
|
3225
|
+
19│ │ M │ R │ R │ R │ R │ R │ R │ P │ P │ P │ P │ P │ P │ P │ P │ P │ P │ R │ R │ R │ R │ R │ R │ M │ M │ M │ P │ P │ R │ R │ │ │ │
|
|
3226
|
+
├───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┤
|
|
3227
|
+
20│ │ M │ R │ R │ R │ R │ R │ R │ R │ P │ P │ P │ P │ P │ R │ R │ R │ R │ R │ R │ R │ R │ R │ M │ M │ M │ P │ P │ P │ R │ R │ │ │ │
|
|
3228
|
+
├───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┤
|
|
3229
|
+
21│ M │ M │ R │ R │ R │ R │ R │ R │ R │ R │ R │ R │ R │ R │ R │ R │ R │ R │ R │ R │ R │ R │ M │ M │ M │ P │ P │ P │ P │ R │ R │ │ │ │
|
|
3230
|
+
├───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┤
|
|
3231
|
+
22│ M │ M │ M │ R │ R │ R │ R │ R │ R │ R │ R │ R │ R │ R │ R │ R │ R │ R │ R │ R │ R │ M │ M │ M │ P │ P │ P │ P │ P │ R │ R │ │ │ │
|
|
3232
|
+
├───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┤
|
|
3233
|
+
23│ M │ M │ M │ M │ R │ R │ R │ R │ R │ R │ R │ R │ R │ R │ R │ R │ R │ R │ R │ R │ M │ M │ M │ P │ P │ P │ P │ P │ P │ R │ R │ │ │ │
|
|
3234
|
+
├───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┤
|
|
3235
|
+
24│ M │ M │ M │ M │ M │ R │ R │ R │ R │ R │ R │ R │ R │ R │ R │ R │ R │ R │ M │ M │ M │ M │ M │ P │ P │ P │ P │ P │ P │ R │ R │ │ │ │
|
|
3236
|
+
├───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┤
|
|
3237
|
+
25│ M │ M │ M │ M │ M │ M │ M │ R │ R │ R │ R │ R │ R │ R │ R │ M │ M │ M │ M │ M │ M │ M │ M │ P │ P │ P │ P │ P │ R │ R │ R │ │ │ │
|
|
3238
|
+
├───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┤
|
|
3239
|
+
26│ │ M │ M │ M │ M │ M │ M │ M │ M │ M │ M │ M │ M │ M │ M │ M │ M │ M │ M │ M │ M │ M │ M │ M │ M │ P │ P │ R │ R │ R │ │ │ │ │
|
|
3240
|
+
├───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┤
|
|
3241
|
+
27│ │ │ M │ M │ M │ M │ M │ M │ M │ M │ M │ M │ M │ M │ M │ M │ M │ M │ │ │ │ M │ M │ M │ M │ M │ M │ M │ │ │ │ │ │ │
|
|
3242
|
+
├───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┤
|
|
3243
|
+
28│ │ │ │ │ │ M │ M │ M │ M │ M │ M │ M │ M │ M │ M │ M │ M │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
|
|
3244
|
+
└───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┘
|
|
3245
|
+
Solutions found: 1
|
|
3246
|
+
status: OPTIMAL
|
|
3247
|
+
Time taken: 0.40 seconds
|
|
3248
|
+
```
|
|
3249
|
+
|
|
3250
|
+
The script also visualizes the solution:
|
|
3251
|
+
|
|
3252
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/nonograms_colored_script_output.png" alt="Nonograms Colored solved" width="500">
|
|
3253
|
+
|
|
3254
|
+
**Solved puzzle**
|
|
3255
|
+
|
|
3256
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/nonograms_colored_solved.png" alt="Nonograms Colored solved" width="500">
|
|
3257
|
+
|
|
3258
|
+
---
|
|
3259
|
+
|
|
3260
|
+
## Split Ends (Puzzle Type #60)
|
|
3261
|
+
|
|
3262
|
+
* [**Play online**](https://krazydad.com/play/splitends/)
|
|
3263
|
+
|
|
3264
|
+
* [**Solver Code**](https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/split_ends)
|
|
3265
|
+
|
|
3266
|
+
<details>
|
|
3267
|
+
<summary><strong>Rules</strong></summary>
|
|
3268
|
+
|
|
3269
|
+
Each row and column contains four unique Y shapes (four different orientations) and two Os. Ys should not form straight lines by touching other Ys.
|
|
3270
|
+
|
|
3271
|
+
</details>
|
|
3272
|
+
|
|
3273
|
+
**Unsolved puzzle**
|
|
3274
|
+
|
|
3275
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/split_ends_unsolved.png" alt="Split Ends unsolved" width="500">
|
|
3276
|
+
|
|
3277
|
+
Code to utilize this package and solve the puzzle:
|
|
3278
|
+
|
|
3279
|
+
Note: the 4 letters ("U", "L", "D", "R") represent the 4 shapes, each letter corresponds to the direction of the cardinal line, so the "Y" shape for example is "D" because the cardinal line is down.
|
|
3280
|
+
|
|
3281
|
+
```python
|
|
3282
|
+
import numpy as np
|
|
3283
|
+
from puzzle_solver import split_ends_solver as solver
|
|
3284
|
+
board = np.array([
|
|
3285
|
+
['O', ' ', 'O', 'L', ' ', 'U'],
|
|
3286
|
+
[' ', ' ', ' ', ' ', ' ', ' '],
|
|
3287
|
+
[' ', 'R', ' ', ' ', 'O', ' '],
|
|
3288
|
+
[' ', 'O', ' ', ' ', 'L', ' '],
|
|
3289
|
+
[' ', ' ', ' ', ' ', ' ', ' '],
|
|
3290
|
+
['U', ' ', 'L', 'D', ' ', 'R'],
|
|
3291
|
+
])
|
|
3292
|
+
binst = solver.Board(board=board)
|
|
3293
|
+
solutions = binst.solve_and_print()
|
|
3294
|
+
```
|
|
3295
|
+
|
|
3296
|
+
**Script Output**
|
|
3297
|
+
|
|
3298
|
+
```python
|
|
3299
|
+
Solution found
|
|
3300
|
+
|
|
3301
|
+
0 1 2 3 4 5
|
|
3302
|
+
┌───┬───┬───┬───┬───┬───┐
|
|
3303
|
+
0│ O │ D │ O │ L │ R │ U │
|
|
3304
|
+
├───┼───┼───┼───┼───┼───┤
|
|
3305
|
+
1│ O │ L │ D │ R │ U │ O │
|
|
3306
|
+
├───┼───┼───┼───┼───┼───┤
|
|
3307
|
+
2│ D │ R │ O │ U │ O │ L │
|
|
3308
|
+
├───┼───┼───┼───┼───┼───┤
|
|
3309
|
+
3│ R │ O │ U │ O │ L │ D │
|
|
3310
|
+
├───┼───┼───┼───┼───┼───┤
|
|
3311
|
+
4│ L │ U │ R │ O │ D │ O │
|
|
3312
|
+
├───┼───┼───┼───┼───┼───┤
|
|
3313
|
+
5│ U │ O │ L │ D │ O │ R │
|
|
3314
|
+
└───┴───┴───┴───┴───┴───┘
|
|
3315
|
+
Solutions found: 1
|
|
3316
|
+
status: OPTIMAL
|
|
3317
|
+
Time taken: 0.01 seconds
|
|
3318
|
+
```
|
|
3319
|
+
|
|
3320
|
+
**Solved puzzle**
|
|
3321
|
+
|
|
3322
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/split_ends_solved.png" alt="Split Ends solved" width="500">
|
|
3323
|
+
|
|
3324
|
+
---
|
|
3325
|
+
|
|
3326
|
+
## N-Queens (Puzzle Type #61)
|
|
3327
|
+
|
|
3328
|
+
Can also solve puzzles such as 7-Queens.
|
|
3329
|
+
|
|
3330
|
+
* [**Play online**](https://krazydad.com/play/queens/)
|
|
3331
|
+
|
|
3332
|
+
* [**Solver Code**](https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/n_queens)
|
|
3333
|
+
|
|
3334
|
+
<details>
|
|
3335
|
+
<summary><strong>Rules</strong></summary>
|
|
3336
|
+
|
|
3337
|
+
7-Queens Variant: Within each of the seven realms lives a lone queen. To maintain the peace, queens must not threaten each other: no row, column, diagonal, nor region may have more than one queen!
|
|
3338
|
+
|
|
3339
|
+
</details>
|
|
3340
|
+
|
|
3341
|
+
**Unsolved puzzle**
|
|
3342
|
+
|
|
3343
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/7_queens_unsolved.png" alt="7 Queens unsolved" width="500">
|
|
3344
|
+
|
|
3345
|
+
Code to utilize this package and solve the puzzle:
|
|
3346
|
+
|
|
3347
|
+
```python
|
|
3348
|
+
import numpy as np
|
|
3349
|
+
from puzzle_solver import n_queens_solver as solver
|
|
3350
|
+
board = np.array([
|
|
3351
|
+
['00', '00', '00', '00', '01', '01', '02', '02'],
|
|
3352
|
+
['00', '00', '03', '03', '01', '01', '02', '04'],
|
|
3353
|
+
['00', '00', '03', '03', '01', '01', '01', '04'],
|
|
3354
|
+
['03', '03', '03', '03', '01', '01', '01', '05'],
|
|
3355
|
+
['03', '03', '03', '03', '01', '01', '01', '05'],
|
|
3356
|
+
['03', '03', '06', '06', '06', '05', '05', '05'],
|
|
3357
|
+
['06', '06', '06', '06', '06', '06', '05', '05'],
|
|
3358
|
+
['06', '06', '06', '06', '06', '06', '05', '05']
|
|
3359
|
+
])
|
|
3360
|
+
binst = solver.Board(board=board)
|
|
3361
|
+
solutions = binst.solve_and_print()
|
|
3362
|
+
```
|
|
3363
|
+
|
|
3364
|
+
**Script Output**
|
|
3365
|
+
|
|
3366
|
+
```python
|
|
3367
|
+
Solution found
|
|
3368
|
+
|
|
3369
|
+
0 1 2 3 4 5 6 7
|
|
3370
|
+
┌───┬───┬───┬───┬───┬───┬───┬───┐
|
|
3371
|
+
0│ │ │ │ │ │ │▒▒▒│ │
|
|
3372
|
+
├───┼───┼───┼───┼───┼───┼───┼───┤
|
|
3373
|
+
1│▒▒▒│ │ │ │ │ │ │ │
|
|
3374
|
+
├───┼───┼───┼───┼───┼───┼───┼───┤
|
|
3375
|
+
2│ │ │ │ │ │ │ │▒▒▒│
|
|
3376
|
+
├───┼───┼───┼───┼───┼───┼───┼───┤
|
|
3377
|
+
3│ │ │ │ │▒▒▒│ │ │ │
|
|
3378
|
+
├───┼───┼───┼───┼───┼───┼───┼───┤
|
|
3379
|
+
4│ │▒▒▒│ │ │ │ │ │ │
|
|
3380
|
+
├───┼───┼───┼───┼───┼───┼───┼───┤
|
|
3381
|
+
5│ │ │ │ │ │▒▒▒│ │ │
|
|
3382
|
+
├───┼───┼───┼───┼───┼───┼───┼───┤
|
|
3383
|
+
6│ │ │▒▒▒│ │ │ │ │ │
|
|
3384
|
+
├───┼───┼───┼───┼───┼───┼───┼───┤
|
|
3385
|
+
7│ │ │ │ │ │ │ │ │
|
|
3386
|
+
└───┴───┴───┴───┴───┴───┴───┴───┘
|
|
3387
|
+
Solutions found: 1
|
|
3388
|
+
status: OPTIMAL
|
|
3389
|
+
Time taken: 0.00 seconds
|
|
3390
|
+
```
|
|
3391
|
+
|
|
3392
|
+
**Solved puzzle**
|
|
3393
|
+
|
|
3394
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/7_queens_solved.png" alt="7 Queens solved" width="500">
|
|
3395
|
+
|
|
3396
|
+
---
|
|
3397
|
+
|
|
3398
|
+
## Suguru (Puzzle Type #66)
|
|
3399
|
+
|
|
3400
|
+
* [**Play online 1**](https://krazydad.com/play/suguru/?kind=15x10n6)
|
|
3401
|
+
|
|
3402
|
+
* [**Play online 2**](https://puzzlemadness.co.uk/suguru/large)
|
|
3403
|
+
|
|
3404
|
+
* [**Solver Code**](https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/suguru)
|
|
3405
|
+
|
|
3406
|
+
<details>
|
|
3407
|
+
<summary><strong>Rules</strong></summary>
|
|
3408
|
+
|
|
3409
|
+
Heavy lines indicate areas, called cages, from 1 to 6 squares in size. Fill each n-sized cage with the numbers 1-n.
|
|
3410
|
+
|
|
3411
|
+
So for example a 2-square cage contains the numbers 1 and 2; and a 5-square cage contains the numbers from 1 to 5.
|
|
3412
|
+
|
|
3413
|
+
Adjacent (touching) squares, even ones that touch diagonally, may never contain the same number.
|
|
3414
|
+
|
|
3415
|
+
</details>
|
|
3416
|
+
|
|
3417
|
+
**Unsolved puzzle**
|
|
3418
|
+
|
|
3419
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/suguru_unsolved.png" alt="Suguru unsolved" width="500">
|
|
3420
|
+
|
|
3421
|
+
Code to utilize this package and solve the puzzle:
|
|
3422
|
+
|
|
3423
|
+
```python
|
|
3424
|
+
import numpy as np
|
|
3425
|
+
from puzzle_solver import suguru_solver as solver
|
|
3426
|
+
id_board = np.array([
|
|
3427
|
+
['00', '00', '00', '00', '00', '01', '01', '02', '02', '02', '03', '03', '03', '03', '04'],
|
|
3428
|
+
['00', '05', '05', '06', '06', '06', '01', '02', '02', '03', '03', '07', '07', '04', '04'],
|
|
3429
|
+
['08', '08', '05', '06', '06', '01', '01', '02', '09', '09', '09', '09', '07', '04', '04'],
|
|
3430
|
+
['08', '05', '05', '06', '10', '01', '11', '11', '12', '13', '13', '07', '07', '14', '04'],
|
|
3431
|
+
['08', '05', '15', '16', '10', '10', '17', '17', '12', '12', '13', '07', '14', '14', '18'],
|
|
3432
|
+
['08', '15', '15', '16', '16', '10', '10', '17', '12', '13', '13', '19', '19', '14', '18'],
|
|
3433
|
+
['15', '15', '20', '20', '16', '10', '17', '17', '12', '13', '21', '21', '19', '22', '18'],
|
|
3434
|
+
['15', '23', '23', '20', '16', '16', '17', '24', '24', '24', '21', '19', '19', '22', '18'],
|
|
3435
|
+
['23', '23', '20', '20', '25', '25', '24', '24', '26', '24', '21', '19', '22', '22', '18'],
|
|
3436
|
+
['23', '23', '20', '25', '25', '25', '25', '26', '26', '26', '21', '21', '22', '22', '18']
|
|
3437
|
+
])
|
|
3438
|
+
num_board = np.array([
|
|
3439
|
+
[' ', '4', ' ', ' ', ' ', ' ', '4', ' ', '3', ' ', ' ', ' ', ' ', ' ', '6'],
|
|
3440
|
+
['6', ' ', '3', ' ', '4', ' ', ' ', ' ', ' ', ' ', '6', ' ', '5', ' ', ' '],
|
|
3441
|
+
[' ', ' ', ' ', ' ', ' ', ' ', '5', '6', '2', ' ', ' ', ' ', ' ', ' ', '3'],
|
|
3442
|
+
[' ', ' ', '5', ' ', '2', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '1'],
|
|
3443
|
+
['5', ' ', ' ', ' ', ' ', '6', ' ', ' ', '5', ' ', ' ', '1', ' ', '2', '6'],
|
|
3444
|
+
[' ', ' ', ' ', '6', '3', ' ', ' ', ' ', ' ', ' ', ' ', '5', ' ', ' ', ' '],
|
|
3445
|
+
[' ', ' ', ' ', ' ', '5', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '],
|
|
3446
|
+
['2', '6', ' ', '4', ' ', ' ', ' ', '1', ' ', ' ', '2', '4', ' ', '5', ' '],
|
|
3447
|
+
['4', '3', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '],
|
|
3448
|
+
['2', ' ', ' ', '3', ' ', ' ', '5', '4', ' ', ' ', '1', ' ', ' ', '2', '3'],
|
|
3449
|
+
])
|
|
3450
|
+
binst = solver.Board(id_board=id_board, num_board=num_board)
|
|
3451
|
+
solutions = binst.solve_and_print()
|
|
3452
|
+
```
|
|
3453
|
+
|
|
3454
|
+
**Script Output**
|
|
3455
|
+
|
|
3456
|
+
```python
|
|
3457
|
+
Solution found
|
|
3458
|
+
0 0 0 0 0 0 0 0 0 0 1 1 1 1 1
|
|
3459
|
+
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4
|
|
3460
|
+
┌───────────────────┬───────┬───────────┬───────────────┬───┐
|
|
3461
|
+
0│ 2 4 5 1 3 │ 2 4 │ 2 3 4 │ 5 4 3 2 │ 6 │
|
|
3462
|
+
│ ┌───────┬───────┴───┐ │ ┌───┘ ┌───────┬───┘ │
|
|
3463
|
+
1│ 6 │ 1 3 │ 2 4 1 │ 3 │ 1 5 │ 1 6 │ 2 5 │ 4 5 │
|
|
3464
|
+
├───┴───┐ │ ┌───┘ │ ┌───┴───────┴───┐ │ │
|
|
3465
|
+
2│ 3 2 │ 4 │ 6 5 │ 6 5 │ 6 │ 2 4 3 1 │ 3 │ 2 3 │
|
|
3466
|
+
│ ┌───┘ │ ┌───┤ ┌───┴───┼───┬───────┬───┘ ├───┐ │
|
|
3467
|
+
3│ 1 │ 6 5 │ 3 │ 2 │ 1 │ 2 1 │ 3 │ 6 5 │ 4 6 │ 4 │ 1 │
|
|
3468
|
+
│ │ ┌───┼───┤ └───┼───────┤ └───┐ │ ┌───┘ ├───┤
|
|
3469
|
+
4│ 5 │ 2 │ 4 │ 1 │ 5 6 │ 5 4 │ 5 1 │ 2 │ 1 │ 3 2 │ 6 │
|
|
3470
|
+
│ ├───┘ │ └───┐ └───┐ │ ┌───┘ ├───┴───┐ │ │
|
|
3471
|
+
5│ 4 │ 6 5 │ 6 3 │ 4 3 │ 1 │ 2 │ 3 4 │ 5 6 │ 1 │ 5 │
|
|
3472
|
+
├───┘ ┌───┴───┐ │ ┌───┘ │ │ ┌───┴───┐ ├───┤ │
|
|
3473
|
+
6│ 3 1 │ 3 1 │ 5 │ 1 │ 2 6 │ 4 │ 1 │ 6 3 │ 2 │ 3 │ 4 │
|
|
3474
|
+
│ ┌───┴───┐ │ └───┤ ┌───┴───┴───┤ ┌───┘ │ │ │
|
|
3475
|
+
7│ 2 │ 6 5 │ 4 │ 2 4 │ 3 │ 1 5 3 │ 2 │ 4 1 │ 5 │ 2 │
|
|
3476
|
+
├───┘ ┌───┘ ├───────┼───┘ ┌───┐ │ │ ┌───┘ │ │
|
|
3477
|
+
8│ 4 3 │ 2 6 │ 1 6 │ 2 6 │ 2 │ 4 │ 5 │ 3 │ 6 4 │ 1 │
|
|
3478
|
+
│ │ ┌───┘ └───┬───┘ └───┤ └───┤ │ │
|
|
3479
|
+
9│ 2 1 │ 5 │ 3 2 4 5 │ 4 1 3 │ 1 4 │ 1 2 │ 3 │
|
|
3480
|
+
└───────┴───┴───────────────┴───────────┴───────┴───────┴───┘
|
|
3481
|
+
Solutions found: 1
|
|
3482
|
+
status: OPTIMAL
|
|
3483
|
+
Time taken: 0.03 seconds
|
|
3484
|
+
```
|
|
3485
|
+
|
|
3486
|
+
**Solved puzzle**
|
|
3487
|
+
|
|
3488
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/suguru_solved.png" alt="Suguru solved" width="500">
|
|
3489
|
+
|
|
3490
|
+
---
|
|
3491
|
+
|
|
3492
|
+
## Yajilin (Puzzle Type #68)
|
|
3493
|
+
|
|
3494
|
+
* [**Play online**](https://puzzlemadness.co.uk/yajilin/hard)
|
|
3495
|
+
|
|
3496
|
+
* [**Instructions**](https://www.nikoli.co.jp/en/puzzles/yajilin/)
|
|
3497
|
+
|
|
3498
|
+
* [**Solver Code**](https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/yajilin)
|
|
3499
|
+
|
|
3500
|
+
<details>
|
|
3501
|
+
<summary><strong>Rules</strong></summary>
|
|
3502
|
+
|
|
3503
|
+
The aim of a Yajilin puzzle is to draw a single closed loop passing through every non-filled and non-clue cell.
|
|
3504
|
+
|
|
3505
|
+
- The clues tell you exactly how many filled cells are in the given direction.
|
|
3506
|
+
|
|
3507
|
+
- Filled cells cannot touch each other (diagonally is fine).
|
|
3508
|
+
|
|
3509
|
+
- There can't be any empty cells - each cell must be a clue, filled, or contain the loop.
|
|
3510
|
+
|
|
3511
|
+
</details>
|
|
3512
|
+
|
|
3513
|
+
**Unsolved puzzle**
|
|
3514
|
+
|
|
3515
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/yajilin_unsolved.png" alt="Yajilin unsolved" width="500">
|
|
3516
|
+
|
|
3517
|
+
Code to utilize this package and solve the puzzle:
|
|
3518
|
+
|
|
3519
|
+
```python
|
|
3520
|
+
import numpy as np
|
|
3521
|
+
from puzzle_solver import yajilin_solver as solver
|
|
3522
|
+
board = np.array([
|
|
3523
|
+
[' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'D1'],
|
|
3524
|
+
[' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '],
|
|
3525
|
+
['D1', ' ', ' ', ' ', ' ', 'D1', ' ', ' ', ' '],
|
|
3526
|
+
[' ', ' ', ' ', 'R2', ' ', ' ', ' ', 'L1', ' '],
|
|
3527
|
+
[' ', ' ', ' ', ' ', ' ', ' ', 'U1', ' ', ' '],
|
|
3528
|
+
[' ', 'U0', ' ', 'D0', ' ', ' ', ' ', ' ', ' '],
|
|
3529
|
+
['R2', ' ', 'U2', ' ', ' ', ' ', ' ', ' ', ' '],
|
|
3530
|
+
[' ', ' ', ' ', ' ', 'U0', ' ', ' ', 'D0', ' '],
|
|
3531
|
+
[' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '],
|
|
3532
|
+
])
|
|
3533
|
+
binst = solver.Board(board=board)
|
|
3534
|
+
solutions = binst.solve_and_print()
|
|
3535
|
+
```
|
|
3536
|
+
|
|
3537
|
+
**Script Output**
|
|
3538
|
+
|
|
3539
|
+
```python
|
|
3540
|
+
Solution found
|
|
3541
|
+
|
|
3542
|
+
0 1 2 3 4 5 6 7 8
|
|
3543
|
+
┌───────────────────────────────────┐
|
|
3544
|
+
0│ ┌───────────────────────────┐ 1↓ │
|
|
3545
|
+
│ │ │ │
|
|
3546
|
+
1│ └───┐ ▒▒▒ ┌───────────┐ └───┐ │
|
|
3547
|
+
│ │ │ │ │ │
|
|
3548
|
+
2│1↓ └───┐ └───┐ 1↓ └───────┘ │
|
|
3549
|
+
│ │ │ │
|
|
3550
|
+
3│ ┌───────┘ 2→ └───┐ ▒▒▒ 1← ▒▒▒│
|
|
3551
|
+
│ │ │ │
|
|
3552
|
+
4│ └───────────────┐ │ 1↑ ┌───┐ │
|
|
3553
|
+
│ │ │ │ │ │
|
|
3554
|
+
5│▒▒▒ 0↑ ▒▒▒ 0↓ │ └───┐ │ │ │
|
|
3555
|
+
│ │ │ │ │ │
|
|
3556
|
+
6│2→ ▒▒▒ 2↑ ┌───┘ ▒▒▒ └───┘ │ │
|
|
3557
|
+
│ │ │ │
|
|
3558
|
+
7│ ┌───────────┘ 0↑ ┌───┐ 0↓ │ │
|
|
3559
|
+
│ │ │ │ │ │
|
|
3560
|
+
8│ └───────────────────┘ └───────┘ │
|
|
3561
|
+
└───────────────────────────────────┘
|
|
3562
|
+
Solutions found: 1
|
|
3563
|
+
status: OPTIMAL
|
|
3564
|
+
Time taken: 0.07 seconds
|
|
3565
|
+
```
|
|
3566
|
+
|
|
3567
|
+
**Solved puzzle**
|
|
3568
|
+
|
|
3569
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/yajilin_solved.png" alt="Yajilin solved" width="500">
|
|
3570
|
+
|
|
3571
|
+
---
|
|
3572
|
+
|
|
3573
|
+
## NumberMaze (Puzzle Type #69)
|
|
3574
|
+
|
|
3575
|
+
Also known as Dot Stream.
|
|
3576
|
+
|
|
3577
|
+
* [**Play online**](https://puzzlemadness.co.uk/numbermaze/hard)
|
|
3578
|
+
|
|
3579
|
+
* [**Solver Code**](https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/numbermaze)
|
|
3580
|
+
|
|
3581
|
+
<details>
|
|
3582
|
+
<summary><strong>Rules</strong></summary>
|
|
3583
|
+
|
|
3584
|
+
Your aim is to draw a single line starting from the number 1 through all of the numbers, covering all of the cells in the grid as you go.
|
|
3585
|
+
|
|
3586
|
+
</details>
|
|
3587
|
+
|
|
3588
|
+
**Unsolved puzzle**
|
|
3589
|
+
|
|
3590
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/numbermaze_unsolved.png" alt="Number Maze unsolved" width="500">
|
|
3591
|
+
|
|
3592
|
+
Code to utilize this package and solve the puzzle:
|
|
3593
|
+
|
|
3594
|
+
```python
|
|
3595
|
+
import numpy as np
|
|
3596
|
+
from puzzle_solver import numbermaze_solver as solver
|
|
3597
|
+
board = np.array([
|
|
3598
|
+
[' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '],
|
|
3599
|
+
[' ', '3', ' ', '5', ' ', ' ', '4', ' ', '7'],
|
|
3600
|
+
[' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '],
|
|
3601
|
+
[' ', '#', ' ', ' ', '#', ' ', '6', '8', ' '],
|
|
3602
|
+
['2', ' ', '#', '#', ' ', ' ', ' ', ' ', ' '],
|
|
3603
|
+
['#', ' ', '1', ' ', ' ', '#', ' ', '#', ' '],
|
|
3604
|
+
[' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '],
|
|
3605
|
+
['9', ' ', '10', ' ', ' ', ' ', '#', ' ', '#'],
|
|
3606
|
+
['#', ' ', ' ', '11', '#', ' ', ' ', ' ', '#'],
|
|
3607
|
+
])
|
|
3608
|
+
binst = solver.Board(board=board)
|
|
3609
|
+
solutions = binst.solve_and_print()
|
|
3610
|
+
```
|
|
3611
|
+
|
|
3612
|
+
**Script Output**
|
|
3613
|
+
|
|
3614
|
+
```python
|
|
3615
|
+
Solution found
|
|
3616
|
+
|
|
3617
|
+
0 1 2 3 4 5 6 7 8
|
|
3618
|
+
┌───────────────────────────────────┐
|
|
3619
|
+
0│ ┌───────────────────────┐ ┌───┐ │
|
|
3620
|
+
│ │ │ │ │ │
|
|
3621
|
+
1│ └───3 ┌───5───────────4 │ 7 │
|
|
3622
|
+
│ │ │ │ │ │
|
|
3623
|
+
2│ ┌───┘ │ ┌───────┐ ┌───┘ │ │
|
|
3624
|
+
│ │ │ │ │ │ │ │
|
|
3625
|
+
3│ │ ▒▒▒ └───┘ ▒▒▒ └───6 8───┘ │
|
|
3626
|
+
│ │ │ │
|
|
3627
|
+
4│ 2───┐ ▒▒▒ ▒▒▒ ┌───────┐ └───┐ │
|
|
3628
|
+
│ │ │ │ │ │
|
|
3629
|
+
5│▒▒▒ └───1 ┌───┘ ▒▒▒ │ ▒▒▒ │ │
|
|
3630
|
+
│ │ │ │ │
|
|
3631
|
+
6│ ┌───────────┘ ┌───────┘ ┌───┘ │
|
|
3632
|
+
│ │ │ │ │
|
|
3633
|
+
7│ 9───┐ 10───┐ └───┐ ▒▒▒ │ ▒▒▒│
|
|
3634
|
+
│ │ │ │ │ │ │
|
|
3635
|
+
8│▒▒▒ └───┘ 11 ▒▒▒ └───────┘ ▒▒▒│
|
|
3636
|
+
└───────────────────────────────────┘
|
|
3637
|
+
Solutions found: 1
|
|
3638
|
+
status: OPTIMAL
|
|
3639
|
+
Time taken: 0.05 seconds
|
|
3640
|
+
```
|
|
3641
|
+
|
|
3642
|
+
**Solved puzzle**
|
|
3643
|
+
|
|
3644
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/numbermaze_solved.png" alt="Number Maze solved" width="500">
|
|
3645
|
+
|
|
3646
|
+
---
|
|
3647
|
+
|
|
3648
|
+
## Link-a-Pix (Puzzle Type #70)
|
|
3649
|
+
|
|
3650
|
+
* [**Play online**](https://en.grandgames.net/filippinskie)
|
|
3651
|
+
|
|
3652
|
+
* [**Solver Code**](https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/link_a_pix)
|
|
3653
|
+
|
|
3654
|
+
<details>
|
|
3655
|
+
<summary><strong>Rules</strong></summary>
|
|
3656
|
+
|
|
3657
|
+
The rules of Link-a-Pix are to link pairs of identical numbers (or color-number) on a grid with a single, continuous path of the length of the number.
|
|
3658
|
+
|
|
3659
|
+
</details>
|
|
3660
|
+
|
|
3661
|
+
**Unsolved puzzle**
|
|
3662
|
+
|
|
3663
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/link_a_pix_unsolved.png" alt="Link-a-Pix unsolved" width="500">
|
|
3664
|
+
|
|
3665
|
+
Code to utilize this package and solve the puzzle:
|
|
3666
|
+
|
|
3667
|
+
Note: the letter before the `_` is the color and is arbitrary as long as the same colors in the board are consistent.
|
|
3668
|
+
|
|
3669
|
+
```python
|
|
3670
|
+
import numpy as np
|
|
3671
|
+
from puzzle_solver import link_a_pix_solver as solver
|
|
3672
|
+
board = np.array([
|
|
3673
|
+
[ '' , '' , '' , '' , '' , '' , '' , 'B_7' , '' , '' , '' , '' , '' , 'B_7' , '' , '' , '' , '' , '' , '' , '' ],
|
|
3674
|
+
[ '' , '' , '' , '' , '' , '' , 'B_1' , '' , 'K_10', 'K_3' , 'K_1' , '' , '' , 'K_6' , 'B_1' , '' , '' , '' , '' , '' , '' ],
|
|
3675
|
+
[ '' , '' , '' , '' , '' , 'B_1' , '' , '' , 'K_3' , '' , '' , '' , 'K_5' , '' , '' , 'B_1' , '' , '' , '' , '' , '' ],
|
|
3676
|
+
[ '' , '' , '' , 'B_8' , '' , '' , '' , 'B_3' , '' , 'B_3' , 'K_6' , 'B_3' , '' , 'B_3' , '' , 'K_5' , '' , 'B_8' , '' , '' , '' ],
|
|
3677
|
+
[ '' , '' , 'B_1' , 'K_7' , '' , '' , 'B_2' , '' , '' , '' , 'B_2' , '' , '' , '' , 'B_3' , 'K_5' , '' , 'K_6' , 'B_1' , '' , '' ],
|
|
3678
|
+
[ '' , 'B_1' , '' , '' , '' , '' , 'B_2' , '' , 'B_3' , '' , 'B_2' , '' , 'B_3' , '' , '' , '' , '' , '' , 'K_7' , 'B_1' , '' ],
|
|
3679
|
+
[ 'B_11', 'K_7' , '' , 'K_6' , '' , '' , 'B_2' , '' , '' , '' , 'B_2' , '' , '' , '' , 'B_3' , '' , '' , '' , '' , 'K_7' , 'B_11' ],
|
|
3680
|
+
[ '' , '' , '' , '' , '' , 'K_10', 'B_2' , '' , 'B_3' , 'B_1' , 'B_2' , 'B_1' , 'B_3' , 'B_1' , 'K_5' , '' , '' , '' , '' , '' , '' ],
|
|
3681
|
+
[ '' , 'K_8' , '' , '' , '' , 'B_1' , '' , 'K_7' , 'K_7' , '' , '' , 'K_3' , 'K_3' , 'K_1' , 'K_5' , 'B_1' , '' , '' , '' , '' , '' ],
|
|
3682
|
+
[ '' , '' , '' , 'K_6' , 'B_8' , 'K_5' , '' , 'K_7' , '' , '' , 'K_3' , 'K_3' , '' , '' , '' , 'K_7' , 'B_8' , 'K_6' , '' , '' , '' ],
|
|
3683
|
+
[ '' , '' , 'K_8' , 'B_6' , '' , '' , '' , '' , '' , 'B_5' , 'B_1' , 'B_5' , 'K_5' , '' , 'K_4' , '' , '' , 'B_6' , '' , 'K_8' , '' ],
|
|
3684
|
+
[ '' , '' , '' , '' , '' , 'K_5' , '' , 'K_2' , 'K_2' , '' , '' , '' , 'K_4' , '' , '' , 'K_1' , '' , '' , '' , '' , '' ],
|
|
3685
|
+
[ '' , '' , '' , '' , 'K_7' , '' , '' , '' , 'K_6' , '' , 'B_3' , '' , 'K_10', '' , 'K_2' , '' , '' , '' , 'K_8' , '' , '' ],
|
|
3686
|
+
[ '' , 'K_6' , '' , '' , '' , 'K_7' , 'K_7' , '' , '' , '' , '' , '' , '' , '' , 'K_2' , 'K_4' , '' , '' , '' , 'K_6' , '' ],
|
|
3687
|
+
[ '' , 'K_3' , '' , '' , '' , '' , '' , 'K_6' , 'K_6' , 'K_1' , 'B_3' , 'K_2' , 'K_2' , '' , '' , '' , 'K_7' , '' , '' , 'K_3' , '' ],
|
|
3688
|
+
[ '' , '' , '' , 'B_6' , '' , '' , '' , '' , '' , 'B_1' , 'K_5' , 'B_1' , '' , '' , 'K_3' , '' , 'K_4' , 'B_6' , '' , '' , '' ],
|
|
3689
|
+
[ 'B_11', 'K_3' , '' , 'K_2' , 'B_3' , 'K_6' , '' , 'K_3' , 'K_1' , '' , '' , 'K_10', '' , 'K_2' , '' , 'K_3' , 'B_3' , 'K_2' , '' , 'K_3' , 'B_11' ],
|
|
3690
|
+
[ '' , 'B_1' , 'K_6' , 'K_2' , '' , 'B_3' , 'K_3' , '' , 'K_5' , '' , 'K_3' , '' , 'K_3' , 'K_2' , 'K_1' , 'B_3' , '' , 'K_2' , 'K_6' , 'B_1' , '' ],
|
|
3691
|
+
[ '' , '' , 'B_2' , 'B_2' , '' , '' , 'B_9' , '' , '' , '' , '' , '' , '' , '' , 'B_9' , '' , '' , 'B_2' , 'B_2' , '' , '' ],
|
|
3692
|
+
[ '' , '' , '' , '' , '' , '' , 'R_4' , '' , '' , 'R_4' , 'Y_1' , 'R_4' , '' , '' , 'R_4' , '' , '' , '' , '' , '' , '' ],
|
|
3693
|
+
])
|
|
3694
|
+
binst = solver.Board(board=board)
|
|
3695
|
+
solutions = binst.solve_and_print()
|
|
3696
|
+
```
|
|
3697
|
+
|
|
3698
|
+
**Script Output**
|
|
3699
|
+
|
|
3700
|
+
```python
|
|
3701
|
+
Solution found
|
|
3702
|
+
0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 2
|
|
3703
|
+
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0
|
|
3704
|
+
┌───────────────────────────┬───────────────────────────┬───────────────────────────┐
|
|
3705
|
+
0│ │ 7 7 7 7 7 7 7 │ │
|
|
3706
|
+
│ ┌───┼───────┬───┬───┬───────────┼───┐ │
|
|
3707
|
+
1│ │ 1 │10 10 │ 3 │ 1 │ 6 6 6 │ 1 │ │
|
|
3708
|
+
│ ┌───┼───┘ ┌───┘ ├───┘ ┌───────┴───┼───┐ │
|
|
3709
|
+
2│ │ 1 │10 10 │ 3 3 │ 6 6 │ 5 5 5 │ 1 │ │
|
|
3710
|
+
│ ┌───────┼───┘ ┌───┴───────┤ ┌───┴───────┐ └───┼───────┐ │
|
|
3711
|
+
3│ │ 8 8 │10 10 │ 3 3 3 │ 6 │ 3 3 3 │ 5 5 │ 8 8 │ │
|
|
3712
|
+
│ ┌───┼───┐ │ ┌───┼───────────┼───┼───────────┼───┬───┤ ┌───┼───┐ │
|
|
3713
|
+
4│ │ 1 │ 7 │ 8 │10 │ 2 │ │ 2 │ │ 3 │ 5 │ 8 │ 6 │ 1 │ │
|
|
3714
|
+
│ ┌───┼───┘ │ │ │ │ ┌───┐ │ │ ┌───┐ │ │ │ │ ├───┼───┐ │
|
|
3715
|
+
5│ │ 1 │ 7 7 │ 8 │10 │ 2 │ │ 3 │ │ 2 │ │ 3 │ │ 3 │ 5 │ 8 │ 6 │ 7 │ 1 │ │
|
|
3716
|
+
├───┼───┘ ┌───┤ │ ├───┤ │ │ ├───┤ │ │ │ │ │ │ │ └───┼───┤
|
|
3717
|
+
6│11 │ 7 7 │ 6 │ 8 │10 │ 2 │ │ 3 │ │ 2 │ │ 3 │ │ 3 │ 5 │ 8 │ 6 │ 7 7 │11 │
|
|
3718
|
+
│ │ │ │ │ │ │ │ ├───┤ ├───┤ ├───┼───┘ │ │ │ │ │
|
|
3719
|
+
7│11 │ 7 7 │ 6 │ 8 │10 │ 2 │ │ 3 │ 1 │ 2 │ 1 │ 3 │ 1 │ 5 5 │ 8 │ 6 │ 7 7 │11 │
|
|
3720
|
+
│ ├───┬───┘ │ ├───┼───┴───┼───┴───┼───┴───┼───┼───┼───┬───┤ │ │ │ │
|
|
3721
|
+
8│11 │ 8 │ 6 6 │ 8 │ 1 │ 7 7 │ 7 7 │ 3 3 │ 3 │ 1 │ 5 │ 1 │ 8 │ 6 │ 7 7 │11 │
|
|
3722
|
+
│ │ │ │ ├───┤ ┌───┘ │ ┌───┘ ├───┘ ├───┤ │ ├───────┤ │
|
|
3723
|
+
9│11 │ 8 │ 6 6 │ 8 │ 5 │ 7 │ 7 7 7 │ 3 │ 3 3 │ 5 5 │ 7 │ 8 │ 6 │ 8 8 │11 │
|
|
3724
|
+
│ │ └───┬───┼───┘ │ │ ┌───┼───┼───┬───┘ ┌───┤ └───┼───┤ │ │
|
|
3725
|
+
10│11 │ 8 8 │ 6 │ 5 5 │ 7 │ 7 7 │ 5 │ 1 │ 5 │ 5 5 │ 4 │ 7 7 │ 6 │ 8 8 │11 │
|
|
3726
|
+
│ │ │ │ │ ├───────┤ └───┘ ├───────┘ ├───┐ │ │ │ │
|
|
3727
|
+
11│11 │ 8 8 │ 6 │ 5 5 │ 7 │ 2 2 │ 5 5 5 │ 4 4 4 │ 1 │ 7 │ 6 │ 8 8 │11 │
|
|
3728
|
+
│ │ │ ├───┬───┤ ├───┬───┴───┬───┬───┴───┬───┬───┼───┤ │ │ │ │
|
|
3729
|
+
12│11 │ 8 8 │ 6 │ 7 │ │ 7 │ │ 6 6 │ 3 │10 10 │ │ 2 │ │ 7 │ 6 │ 8 8 │11 │
|
|
3730
|
+
│ ├───────┤ │ └───┤ ├───┘ │ │ └───┤ ├───┤ │ ├───────┤ │
|
|
3731
|
+
13│11 │ 6 6 │ 6 │ 7 7 │ 7 │ 6 6 6 │ 3 │10 10 10 │ 2 │ 4 │ 7 │ 6 │ 6 6 │11 │
|
|
3732
|
+
│ ├───┐ │ │ ├───┤ ┌───┬───┤ ├───────┐ ├───┤ │ │ │ ┌───┤ │
|
|
3733
|
+
14│11 │ 3 │ 6 │ 6 │ 7 7 │ │ 6 │ 6 │ 1 │ 3 │ 2 2 │10 │ │ 4 │ 7 │ 6 │ 6 │ 3 │11 │
|
|
3734
|
+
│ │ │ │ │ ├───┴───┘ ├───┼───┼───┬───┘ ├───┤ └───┤ │ │ │ │
|
|
3735
|
+
15│11 │ 3 │ 6 │ 6 │ 7 7 │ 6 6 6 │ 1 │ 5 │ 1 │10 10 │ 3 │ 4 4 │ 6 │ 6 │ 3 │11 │
|
|
3736
|
+
│ │ │ ├───┼───┬───┘ ┌───┬───┼───┘ ├───┘ ┌───┤ └───┬───┼───┤ │ │ │
|
|
3737
|
+
16│11 │ 3 │ 6 │ 2 │ 3 │ 6 6 │ 3 │ 1 │ 5 5 │10 10 │ 2 │ 3 3 │ 3 │ 2 │ 6 │ 3 │11 │
|
|
3738
|
+
├───┼───┤ │ │ └───┬───┘ ├───┘ ┌───┴───────┤ ├───┬───┘ │ │ ├───┼───┤
|
|
3739
|
+
17│ │ 1 │ 6 │ 2 │ 3 3 │ 3 3 │ 5 5 │ 3 3 3 │ 2 │ 1 │ 3 3 │ 2 │ 6 │ 1 │ │
|
|
3740
|
+
│ └───┼───┴───┼───────┼───────┴───────┴───────────┴───┴───┼───────┼───┴───┼───┘ │
|
|
3741
|
+
18│ │ 2 2 │ │ 9 9 9 9 9 9 9 9 9 │ │ 2 2 │ │
|
|
3742
|
+
│ └───────┘ ├───────────────┬───┬───────────────┤ └───────┘ │
|
|
3743
|
+
19│ │ 4 4 4 4 │ 1 │ 4 4 4 4 │ │
|
|
3744
|
+
└───────────────────────┴───────────────┴───┴───────────────┴───────────────────────┘
|
|
3745
|
+
Solutions found: 1
|
|
3746
|
+
status: OPTIMAL
|
|
3747
|
+
Time taken: 0.01 seconds
|
|
3748
|
+
```
|
|
3749
|
+
|
|
3750
|
+
**Solved puzzle**
|
|
3751
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/link_a_pix_solved.png" alt="Link-a-Pix solved" width="500">
|
|
3752
|
+
|
|
3753
|
+
---
|
|
3754
|
+
|
|
3755
|
+
## Vectors (Puzzle Type #72)
|
|
3756
|
+
|
|
3757
|
+
* [**Play online**](https://vectors.puzzlebaron.com/init.php)
|
|
3758
|
+
|
|
3759
|
+
* [**Solver Code**](https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/vectors)
|
|
3760
|
+
|
|
3761
|
+
<details>
|
|
3762
|
+
<summary><strong>Rules</strong></summary>
|
|
3763
|
+
|
|
3764
|
+
The puzzle grid consists of a series of numbered black squares. Your task is to draw arrows starting from each of these black squares in such a way so that the total number of white squares covered by arrows emanating from any black square equals exactly the number displayed. Arrows can go up, down, left or right, but can never cross another arrow. You must also fill every empty square on the grid with one arrow segment. Each puzzle has only one unique solution, and each can be solved using pure logical deduction.
|
|
3765
|
+
|
|
3766
|
+
- Every numbered black square must have exactly that number of combined arrow lengths emanating from it in the final solution.
|
|
3767
|
+
- No two arrows can cross each other.
|
|
3768
|
+
- Every square on the grid must be filled with an arrow.
|
|
3769
|
+
- A number will turn green once it has arrows emanating from it with the correct combined length, but that does not necessarily mean those arrows are placed correctly.
|
|
3770
|
+
|
|
3771
|
+
</details>
|
|
3772
|
+
|
|
3773
|
+
**Unsolved puzzle**
|
|
3774
|
+
|
|
3775
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/vectors_unsolved.png" alt="Vectors unsolved" width="500">
|
|
3776
|
+
|
|
3777
|
+
Code to utilize this package and solve the puzzle:
|
|
3778
|
+
|
|
3779
|
+
```python
|
|
3780
|
+
import numpy as np
|
|
3781
|
+
from puzzle_solver import vectors_solver as solver
|
|
3782
|
+
board = np.array([
|
|
3783
|
+
[' ', ' ', ' ', ' ', ' ', ' ', '11', ' ', ' ', ' ', ' ', ' ', ' ', '1 ', ' '],
|
|
3784
|
+
[' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '6 ', ' ', ' '],
|
|
3785
|
+
['5 ', ' ', ' ', '1 ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '5 ', ' ', '1 ', ' '],
|
|
3786
|
+
[' ', ' ', '5 ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '11'],
|
|
3787
|
+
[' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '5 ', ' ', ' ', '9 ', ' '],
|
|
3788
|
+
[' ', ' ', '2 ', ' ', ' ', '13', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '],
|
|
3789
|
+
['1 ', ' ', ' ', ' ', ' ', ' ', ' ', '12', ' ', ' ', ' ', ' ', ' ', ' ', ' '],
|
|
3790
|
+
[' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '2 ', ' ', ' ', ' ', ' '],
|
|
3791
|
+
['2 ', ' ', ' ', '5 ', ' ', '5 ', ' ', ' ', ' ', '2 ', ' ', '6 ', ' ', ' ', ' '],
|
|
3792
|
+
[' ', ' ', ' ', ' ', ' ', ' ', '2 ', ' ', '6 ', ' ', ' ', ' ', ' ', ' ', ' '],
|
|
3793
|
+
[' ', ' ', '2 ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '5 ', ' ', ' ', ' ', ' '],
|
|
3794
|
+
['3 ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '1 ', ' ', ' ', ' ', ' ', '6 '],
|
|
3795
|
+
[' ', '15', ' ', '4 ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '],
|
|
3796
|
+
[' ', ' ', ' ', ' ', ' ', ' ', '3 ', ' ', ' ', '2 ', ' ', ' ', ' ', ' ', '1 '],
|
|
3797
|
+
[' ', ' ', '1 ', ' ', '15', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '13', ' ', ' '],
|
|
3798
|
+
])
|
|
3799
|
+
binst = solver.Board(board=board)
|
|
3800
|
+
solutions = binst.solve_and_print()
|
|
3801
|
+
```
|
|
3802
|
+
|
|
3803
|
+
**Script Output**
|
|
3804
|
+
|
|
3805
|
+
```python
|
|
3806
|
+
Solution found
|
|
3807
|
+
0 0 0 0 0 0 0 0 0 0 1 1 1 1 1
|
|
3808
|
+
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4
|
|
3809
|
+
┌───┬───┬───┬───────────────────────────────────┬───┬───────┐
|
|
3810
|
+
0│ │ │ │ 11 │ │ 1 │
|
|
3811
|
+
│ │ │ ├───┬───┬───┐ ┌───────────────────┘ ├───┬───┤
|
|
3812
|
+
1│ │ │ │ │ │ │ │ 6 │ │ │
|
|
3813
|
+
│ │ │ │ │ │ │ ├───────────────────────┤ │ │
|
|
3814
|
+
2│ 5 │ │ │ 1 │ │ │ │ 5 │ 1 │ │
|
|
3815
|
+
│ │ │ └───┤ │ │ ├───────────────────────┴───┘ │
|
|
3816
|
+
3│ │ │ 5 │ │ │ │ 11 │
|
|
3817
|
+
│ │ │ ┌───┤ │ ├───┴───────────────────┬───────┐ │
|
|
3818
|
+
4│ │ │ │ │ │ │ 5 │ 9 │ │
|
|
3819
|
+
│ │ ├───┤ │ │ └───────────────────────┴───┐ │ │
|
|
3820
|
+
5│ │ │ 2 │ │ │13 │ │ │
|
|
3821
|
+
├───┤ │ │ │ │ ┌───────────────────────────┤ ├───┤
|
|
3822
|
+
6│ 1 │ │ │ │ │ │ 12 │ │ │
|
|
3823
|
+
│ │ │ │ │ │ ├───┐ ┌───┬───┬───────────┤ │ │
|
|
3824
|
+
7│ │ │ │ │ │ │ │ │ │ │ 2 │ │ │
|
|
3825
|
+
├───┤ ├───┘ │ ├───┤ │ │ │ └───┬───────┤ │ │
|
|
3826
|
+
8│ 2 │ │ 5 │ │ 5 │ │ │ │ 2 │ 6 │ │ │
|
|
3827
|
+
│ │ ├───┬───┤ │ │ │ │ └───┬───┤ ┌───┤ │ │
|
|
3828
|
+
9│ │ │ │ │ │ │ 2 │ │ 6 │ │ │ │ │ │
|
|
3829
|
+
│ │ │ │ │ │ ├───┤ │ ┌───┘ │ │ │ │ │
|
|
3830
|
+
10│ │ │ 2 │ │ │ │ │ │ │ 5 │ │ │ │ │
|
|
3831
|
+
├───┤ │ │ │ │ │ │ │ ├───┐ │ │ │ │ │
|
|
3832
|
+
11│ 3 │ │ │ │ │ │ │ │ │ 1 │ │ │ │ │ 6 │
|
|
3833
|
+
│ │ └───┤ │ │ │ │ │ │ │ │ │ │ │ │
|
|
3834
|
+
12│ │15 │ 4 │ │ │ │ │ │ │ │ │ │ │ │
|
|
3835
|
+
│ │ ┌───┤ │ │ │ ├───┴───┴───┤ │ │ ├───┴───┤
|
|
3836
|
+
13│ │ │ │ │ │ │ 3 │ 2 │ │ │ │ 1 │
|
|
3837
|
+
│ │ │ ├───┘ └───┼───┴───────────┴───┴───┘ └───────┤
|
|
3838
|
+
14│ │ │ 1 │ 15 │ 13 │
|
|
3839
|
+
└───┴───┴───┴───────────┴───────────────────────────────────┘
|
|
3840
|
+
Solutions found: 1
|
|
3841
|
+
status: OPTIMAL
|
|
3842
|
+
Time taken: 0.03 seconds
|
|
3843
|
+
```
|
|
3844
|
+
|
|
3845
|
+
**Solved puzzle**
|
|
3846
|
+
|
|
3847
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/vectors_solved.png" alt="Vectors solved" width="500">
|
|
3848
|
+
|
|
3849
|
+
---
|
|
3850
|
+
|
|
3851
|
+
## Vermicelli (Puzzle Type #73)
|
|
3852
|
+
|
|
3853
|
+
* [**Play online**](https://krazydad.com/play/vermicelli)
|
|
3854
|
+
|
|
3855
|
+
* [**Solver Code**](https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/vermicelli)
|
|
3856
|
+
|
|
3857
|
+
<details>
|
|
3858
|
+
<summary><strong>Rules</strong></summary>
|
|
3859
|
+
|
|
3860
|
+
Connect worms to make a loop that visits every square in the grid. The worm can’t fork nor cross itself, and it can't go through walls.
|
|
3861
|
+
|
|
3862
|
+
</details>
|
|
3863
|
+
|
|
3864
|
+
**Unsolved puzzle**
|
|
3865
|
+
|
|
3866
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/vermicelli_unsolved.png" alt="Vermicelli unsolved" width="500">
|
|
3867
|
+
|
|
3868
|
+
Code to utilize this package and solve the puzzle:
|
|
3869
|
+
|
|
3870
|
+
```python
|
|
3871
|
+
import numpy as np
|
|
3872
|
+
from puzzle_solver import vermicelli_solver as solver
|
|
3873
|
+
walls = np.array([
|
|
3874
|
+
[' ', ' ', ' ', 'D ', ' ', ' ', 'R ', ' ', ' ', ' '],
|
|
3875
|
+
[' ', 'D ', ' ', ' ', ' ', 'R ', 'D ', ' ', ' ', ' '],
|
|
3876
|
+
['R ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '],
|
|
3877
|
+
[' ', ' ', 'D ', ' ', ' ', ' ', ' ', ' ', 'R ', ' '],
|
|
3878
|
+
['D ', ' ', 'R ', 'D ', ' ', 'DR', ' ', 'R ', 'D ', ' '],
|
|
3879
|
+
[' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '],
|
|
3880
|
+
[' ', 'D ', 'R ', 'D ', ' ', ' ', ' ', ' ', ' ', ' '],
|
|
3881
|
+
[' ', ' ', ' ', ' ', ' ', 'R ', ' ', ' ', 'U ', ' '],
|
|
3882
|
+
])
|
|
3883
|
+
binst = solver.Board(walls=walls)
|
|
3884
|
+
solutions = binst.solve_and_print()
|
|
3885
|
+
```
|
|
3886
|
+
|
|
3887
|
+
**Script Output**
|
|
3888
|
+
|
|
3889
|
+
```python
|
|
3890
|
+
Solution found
|
|
3891
|
+
0 0 0 0 0 0 0 0 0 0
|
|
3892
|
+
0 1 2 3 4 5 6 7 8 9
|
|
3893
|
+
│
|
|
3894
|
+
0 ┌───┐ ┌───────┐ ┌───┐ │ ┌───────┐
|
|
3895
|
+
│ │ │ ───── │ │ │ │ │ │ │
|
|
3896
|
+
1 │ └───┘ ┌───┘ │ │ └───┘ ┌───┘
|
|
3897
|
+
│ ┌──── │ │ └──── │
|
|
3898
|
+
2 │ │ ┌───────┘ ┌───┘ ┌───┐ └───┐
|
|
3899
|
+
│ │ │ │ │ │ │ │
|
|
3900
|
+
3 │ └───────┐ └───┐ │ └───┐ │ │
|
|
3901
|
+
│ ────┐ │ │ │ │ │ │ │ │
|
|
3902
|
+
4 └───────┐ │ └───────┘ │ └───┐ │ └───┘
|
|
3903
|
+
───── │ └──── ────┘ │ └────
|
|
3904
|
+
5 ┌───┐ │ ┌───────────┐ │ ┌───┐
|
|
3905
|
+
│ │ │ │ │ │ │ │ │
|
|
3906
|
+
6 │ └───┘ │ └───────┐ │ └───┘ │
|
|
3907
|
+
│ ───── └──── │ │ │ ───── │
|
|
3908
|
+
7 └───────────────────┘ │ └───────────┘
|
|
3909
|
+
│
|
|
3910
|
+
Solutions found: 1
|
|
3911
|
+
status: OPTIMAL
|
|
3912
|
+
Time taken: 0.04 seconds
|
|
3913
|
+
```
|
|
3914
|
+
|
|
3915
|
+
**Solved puzzle**
|
|
3916
|
+
|
|
3917
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/vermicelli_solved.png" alt="Vermicelli solved" width="500">
|
|
3918
|
+
|
|
3919
|
+
---
|
|
3920
|
+
|
|
3921
|
+
## Cow and Cactus (Puzzle Type #74)
|
|
3922
|
+
|
|
3923
|
+
* [**Play online**](https://krazydad.com/play/corral)
|
|
3924
|
+
|
|
3925
|
+
* [**Solver Code**](https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/cow_and_cactus)
|
|
3926
|
+
|
|
3927
|
+
<details>
|
|
3928
|
+
<summary><strong>Rules</strong></summary>
|
|
3929
|
+
|
|
3930
|
+
You are building a fence for your ranch. The fence must separate the cows inside, from the cacti outside.
|
|
3931
|
+
|
|
3932
|
+
The finished fence must make an enclosed circuit without touching or crossing itself.
|
|
3933
|
+
|
|
3934
|
+
Numbers inside dotted-circles are corral clues. These squares must be inside the fence. The number shows how many cells can be seen up, down, left, and right (plus itself) from that location before reaching a fence.
|
|
3935
|
+
|
|
3936
|
+
</details>
|
|
3937
|
+
|
|
3938
|
+
**Unsolved puzzle**
|
|
3939
|
+
|
|
3940
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/cow_and_cactus_unsolved.png" alt="Cow and Cactus unsolved" width="500">
|
|
3941
|
+
|
|
3942
|
+
Code to utilize this package and solve the puzzle:
|
|
3943
|
+
|
|
3944
|
+
Note: `W` refers to a cow and `P` refers to a cactus (sadly both words start with 'C' so we have to avoid using that)
|
|
3945
|
+
|
|
3946
|
+
```python
|
|
3947
|
+
import numpy as np
|
|
3948
|
+
from puzzle_solver import cow_and_cactus_solver as solver
|
|
3949
|
+
board = np.array([
|
|
3950
|
+
[' ', ' ', '15', ' ', '11', '9 ', '8 ', '11'],
|
|
3951
|
+
[' ', ' ', ' ', 'P ', ' ', ' ', ' ', ' '],
|
|
3952
|
+
['W ', '3 ', ' ', ' ', ' ', ' ', ' ', ' '],
|
|
3953
|
+
['W ', ' ', ' ', ' ', ' ', ' ', ' ', ' '],
|
|
3954
|
+
['W ', ' ', ' ', ' ', ' ', 'W ', ' ', ' '],
|
|
3955
|
+
[' ', ' ', ' ', ' ', ' ', ' ', '4 ', ' '],
|
|
3956
|
+
['W ', ' ', ' ', ' ', 'W ', 'W ', 'P ', 'W '],
|
|
3957
|
+
['P ', 'W ', ' ', ' ', 'W ', 'W ', ' ', 'P '],
|
|
3958
|
+
])
|
|
3959
|
+
binst = solver.Board(board=board)
|
|
3960
|
+
solutions = binst.solve_and_print()
|
|
3961
|
+
```
|
|
3962
|
+
|
|
3963
|
+
**Script Output**
|
|
3964
|
+
|
|
3965
|
+
```python
|
|
3966
|
+
Solution:
|
|
3967
|
+
|
|
3968
|
+
0 1 2 3 4 5 6 7
|
|
3969
|
+
┌───────────────────────────────┐
|
|
3970
|
+
0│ 15 11 9 8 11 │
|
|
3971
|
+
├───────┐ ┌───┐ ┌───┐ │
|
|
3972
|
+
1│ │ │ P │ │ │ │
|
|
3973
|
+
├───────┘ │ │ ┌───┘ │ │
|
|
3974
|
+
2│ W 3 │ │ │ │ │
|
|
3975
|
+
│ ┌───┐ │ │ └───┐ │ │
|
|
3976
|
+
3│ W │ │ │ │ │ │ │
|
|
3977
|
+
│ │ │ │ └───┐ │ └───┤
|
|
3978
|
+
4│ W │ │ │ │ W │ │
|
|
3979
|
+
├───┘ │ │ ┌───┘ └───────┤
|
|
3980
|
+
5│ │ │ │ 4 │
|
|
3981
|
+
├───────┘ │ │ ┌───┐ │
|
|
3982
|
+
6│ W │ │ W W │ P │ W │
|
|
3983
|
+
├───┐ │ │ │ └───┤
|
|
3984
|
+
7│ P │ W │ │ W W │ P │
|
|
3985
|
+
└───┴───────┴───┴───────┴───────┘
|
|
3986
|
+
Solutions found: 1
|
|
3987
|
+
status: OPTIMAL
|
|
3988
|
+
Time taken: 0.04 seconds
|
|
3989
|
+
```
|
|
3990
|
+
|
|
3991
|
+
**Solved puzzle**
|
|
3992
|
+
|
|
3993
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/cow_and_cactus_solved.png" alt="Cow and Cactus solved" width="500">
|
|
3994
|
+
|
|
3995
|
+
---
|
|
3996
|
+
|
|
3997
|
+
## Ripple Effect (Puzzle Type #76)
|
|
3998
|
+
|
|
3999
|
+
* [**Play online**](https://krazydad.com/play/ripple)
|
|
4000
|
+
|
|
4001
|
+
* [**Solver Code**](https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/ripple_effect)
|
|
4002
|
+
|
|
4003
|
+
<details>
|
|
4004
|
+
<summary><strong>Rules</strong></summary>
|
|
4005
|
+
|
|
4006
|
+
Heavy lines indicate areas, called cages, from 1 to 9 cells in size.
|
|
4007
|
+
|
|
4008
|
+
Fill each cage with unique digits, counting up from 1. So for example a 2-cell cage contains the numbers 1 and 2; and a 5-cell cage contains all the numbers from 1 to 5.
|
|
4009
|
+
|
|
4010
|
+
If two identical numbers appear in the same row or column, at least that many cells must separate them. For example, if two 3s appear in the same column, they must be separated by at least three other cells that do not contain 3.
|
|
4011
|
+
|
|
4012
|
+
This puzzle is a variant of Suguru in which the clues create curious cascading effects.
|
|
4013
|
+
|
|
4014
|
+
</details>
|
|
4015
|
+
|
|
4016
|
+
**Unsolved puzzle**
|
|
4017
|
+
|
|
4018
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/ripple_effect_unsolved.png" alt="Ripple Effect unsolved" width="500">
|
|
4019
|
+
|
|
4020
|
+
Code to utilize this package and solve the puzzle:
|
|
4021
|
+
|
|
4022
|
+
```python
|
|
4023
|
+
import numpy as np
|
|
4024
|
+
from puzzle_solver import ripple_effect_solver as solver
|
|
4025
|
+
id_board = np.array([
|
|
4026
|
+
['00', '01', '02', '02', '03', '03', '04'],
|
|
4027
|
+
['00', '05', '05', '02', '03', '06', '06'],
|
|
4028
|
+
['07', '07', '05', '08', '03', '03', '06'],
|
|
4029
|
+
['09', '07', '07', '07', '03', '10', '10'],
|
|
4030
|
+
['11', '11', '12', '12', '13', '13', '10'],
|
|
4031
|
+
['14', '11', '14', '12', '13', '15', '15'],
|
|
4032
|
+
['14', '14', '14', '16', '13', '13', '15']
|
|
4033
|
+
])
|
|
4034
|
+
board = np.array([
|
|
4035
|
+
[' ', ' ', ' ', ' ', ' ', ' ', ' '],
|
|
4036
|
+
[' ', ' ', ' ', ' ', ' ', ' ', ' '],
|
|
4037
|
+
[' ', ' ', ' ', ' ', ' ', '5', ' '],
|
|
4038
|
+
[' ', ' ', '4', ' ', '6', ' ', ' '],
|
|
4039
|
+
[' ', ' ', ' ', ' ', ' ', ' ', '1'],
|
|
4040
|
+
[' ', ' ', '1', ' ', ' ', ' ', ' '],
|
|
4041
|
+
[' ', '4', ' ', ' ', ' ', ' ', ' '],
|
|
4042
|
+
])
|
|
4043
|
+
binst = solver.Board(board=board, id_board=id_board)
|
|
4044
|
+
solutions = binst.solve_and_print()
|
|
4045
|
+
```
|
|
4046
|
+
|
|
4047
|
+
**Script Output**
|
|
4048
|
+
|
|
4049
|
+
```python
|
|
4050
|
+
Solution found
|
|
4051
|
+
|
|
4052
|
+
0 1 2 3 4 5 6
|
|
4053
|
+
┌───┬───┬───────┬───────┬───┐
|
|
4054
|
+
0│ 2 │ 1 │ 3 1 │ 4 2 │ 1 │
|
|
4055
|
+
│ ├───┴───┐ │ ┌───┴───┤
|
|
4056
|
+
1│ 1 │ 3 1 │ 2 │ 1 │ 3 2 │
|
|
4057
|
+
├───┴───┐ ├───┤ └───┐ │
|
|
4058
|
+
2│ 3 1 │ 2 │ 1 │ 3 5 │ 1 │
|
|
4059
|
+
├───┐ └───┴───┤ ┌───┴───┤
|
|
4060
|
+
3│ 1 │ 2 4 5 │ 6 │ 2 3 │
|
|
4061
|
+
├───┴───┬───────┼───┴───┐ │
|
|
4062
|
+
4│ 2 1 │ 3 1 │ 5 4 │ 1 │
|
|
4063
|
+
├───┐ ├───┐ │ ┌───┴───┤
|
|
4064
|
+
5│ 5 │ 3 │ 1 │ 2 │ 1 │ 3 2 │
|
|
4065
|
+
│ └───┘ ├───┤ └───┐ │
|
|
4066
|
+
6│ 3 4 2 │ 1 │ 3 2 │ 1 │
|
|
4067
|
+
└───────────┴───┴───────┴───┘
|
|
4068
|
+
Solutions found: 1
|
|
4069
|
+
status: OPTIMAL
|
|
4070
|
+
Time taken: 0.05 seconds
|
|
4071
|
+
```
|
|
4072
|
+
|
|
4073
|
+
**Solved puzzle**
|
|
4074
|
+
|
|
4075
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/ripple_effect_solved.png" alt="Ripple Effect solved" width="500">
|
|
4076
|
+
|
|
4077
|
+
---
|
|
4078
|
+
|
|
4079
|
+
## Area 51 (Puzzle Type #77)
|
|
4080
|
+
|
|
4081
|
+
* [**Play online**](https://krazydad.com/play/area51)
|
|
4082
|
+
|
|
4083
|
+
* [**Solver Code**](https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/area_51)
|
|
4084
|
+
|
|
4085
|
+
<details>
|
|
4086
|
+
<summary><strong>Rules</strong></summary>
|
|
4087
|
+
|
|
4088
|
+
You are building a labyrinthian fence enclosing Area 51. The fence must separate the aliens, kept inside, from the cacti, which are outside. The finished fence must make an enclosed circuit without touching or crossing itself.
|
|
4089
|
+
|
|
4090
|
+
A cell containing an uncircled digit must be surrounded by that many pieces of fence.
|
|
4091
|
+
|
|
4092
|
+
Numbers inside dotted-circles must be inside the fence and show how many cells can be seen up, down, left, and right (plus itself) from that cell before reaching a fence.
|
|
4093
|
+
|
|
4094
|
+
On black circles the fence must have a 90 degree turn with two straight sections before and after. On white circles the fence must continue straight with at least one turn immediately before or after the circle.
|
|
4095
|
+
|
|
4096
|
+
</details>
|
|
4097
|
+
|
|
4098
|
+
**Unsolved puzzle**
|
|
4099
|
+
|
|
4100
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/area_51_unsolved.png" alt="Area 51 unsolved" width="500">
|
|
4101
|
+
|
|
4102
|
+
Code to utilize this package and solve the puzzle:
|
|
4103
|
+
|
|
4104
|
+
```python
|
|
4105
|
+
import numpy as np
|
|
4106
|
+
from puzzle_solver import area_51_solver as solver
|
|
4107
|
+
board = np.array([
|
|
4108
|
+
[' ', 'A ', ' ', ' ', ' ', ' ', ' ', 'O4'],
|
|
4109
|
+
[' ', ' ', ' ', '2 ', ' ', ' ', ' ', ' '],
|
|
4110
|
+
[' ', ' ', ' ', '1 ', ' ', '1 ', '3 ', 'C '],
|
|
4111
|
+
[' ', ' ', ' ', ' ', ' ', ' ', '2 ', ' '],
|
|
4112
|
+
[' ', ' ', '2 ', '1 ', '2 ', '1 ', ' ', ' '],
|
|
4113
|
+
[' ', ' ', ' ', '2 ', '3 ', ' ', '2 ', ' '],
|
|
4114
|
+
[' ', ' ', '1 ', ' ', ' ', ' ', '3 ', ' '],
|
|
4115
|
+
[' ', ' ', ' ', ' ', '1 ', ' ', ' ', ' '],
|
|
4116
|
+
[' ', ' ', '1 ', ' ', ' ', ' ', ' ', '2 '],
|
|
4117
|
+
['3 ', ' ', ' ', ' ', ' ', ' ', ' ', ' '],
|
|
4118
|
+
])
|
|
4119
|
+
dots = {
|
|
4120
|
+
get_pos(x=1, y=1): 'B',
|
|
4121
|
+
get_pos(x=5, y=7): 'B',
|
|
4122
|
+
get_pos(x=5, y=1): 'W', get_pos(x=0, y=5): 'W', get_pos(x=1, y=6): 'W', get_pos(x=1, y=7): 'W',
|
|
4123
|
+
get_pos(x=7, y=7): 'W',
|
|
4124
|
+
get_pos(x=6, y=8): 'W',
|
|
4125
|
+
get_pos(x=6, y=9): 'W',
|
|
4126
|
+
get_pos(x=2, y=10): 'W',
|
|
4127
|
+
}
|
|
4128
|
+
binst = solver.Board(board=board, dots=dots)
|
|
4129
|
+
solutions = binst.solve_and_print()
|
|
4130
|
+
```
|
|
4131
|
+
|
|
4132
|
+
**Script Output**
|
|
4133
|
+
|
|
4134
|
+
```python
|
|
4135
|
+
Solution:
|
|
4136
|
+
|
|
4137
|
+
0 1 2 3 4 5 6 7
|
|
4138
|
+
┌───────────────┐ ┌───────────┐
|
|
4139
|
+
0│ A │ │ O4 │
|
|
4140
|
+
│ ┌───────┐ │ │ │
|
|
4141
|
+
1│ │ │ 2 │ │ │
|
|
4142
|
+
│ │ ┌───┘ └───┘ ┌───────┘
|
|
4143
|
+
2│ │ │ 1 1 │ 3 C
|
|
4144
|
+
└───┘ └───────────┐ └───────┐
|
|
4145
|
+
3 │ 2 │
|
|
4146
|
+
┌───┐ ┌───────────┘ ┌───────┘
|
|
4147
|
+
4│ │ │ 2 1 2 1 │
|
|
4148
|
+
│ └───┘ ┌───┐ └───────┐
|
|
4149
|
+
5│ 2 │ 3 │ 2 │
|
|
4150
|
+
└───────────────┘ │ ┌───────┘
|
|
4151
|
+
6 1 │ │ 3
|
|
4152
|
+
┌───────┐ ┌───────┘ └───────┐
|
|
4153
|
+
7│ │ │ 1 │
|
|
4154
|
+
└───┐ └───┘ ┌───────────┘
|
|
4155
|
+
8 │ 1 │ 2
|
|
4156
|
+
┌───┘ ┌───┐ └───────────┐
|
|
4157
|
+
9│ 3 │ │ │
|
|
4158
|
+
└───────────┘ └───────────────┘
|
|
4159
|
+
Solutions found: 1
|
|
4160
|
+
status: OPTIMAL
|
|
4161
|
+
Time taken: 0.05 seconds
|
|
4162
|
+
```
|
|
4163
|
+
|
|
4164
|
+
**Solved puzzle**
|
|
4165
|
+
|
|
4166
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/puzzles/area_51_solved.png" alt="Area 51 solved" width="500">
|
|
4167
|
+
|
|
4168
|
+
---
|
|
4169
|
+
|
|
4170
|
+
## All other Puzzles
|
|
4171
|
+
|
|
4172
|
+
The examples above showcase just a few of the many puzzle types this solver can handle.
|
|
4173
|
+
The repository includes solvers for countless unique challenges.
|
|
4174
|
+
|
|
4175
|
+
Visit the [**Puzzle Gallery**](#puzzle-gallery) to explore **all supported puzzle types**, view their rule summaries, and see visual examples of each one in action.
|
|
4176
|
+
|
|
4177
|
+
### Aliases
|
|
4178
|
+
|
|
4179
|
+
Here is a list of all the puzzles along with some of their aliases:
|
|
4180
|
+
|
|
4181
|
+
<!-- AUTO-GENERATED ALIASES START -->
|
|
4182
|
+
|
|
4183
|
+
01. [Nonograms](https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/nonograms) (Also known as Nonogrids, Numbergrids, Picross, Hanjie, Paint by Numbers, Griddlers, or Pic-a-Pix)
|
|
4184
|
+
02. [Sudoku](https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/sudoku) (Also known as Number Place or Solo)
|
|
4185
|
+
03. [Minesweeper](https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/minesweeper)
|
|
4186
|
+
04. [Dominosa](https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/dominosa)
|
|
4187
|
+
05. [Light Up](https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/light_up) (Also known as Akari or Lasergrids)
|
|
4188
|
+
06. [Tents](https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/tents)
|
|
4189
|
+
07. [Filling](https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/filling) (Also known as Fillomino)
|
|
4190
|
+
08. [Keen](https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/keen) (Also known as KenKen, CalcuDoku, Mathdoku, Inkies, or Inky)
|
|
4191
|
+
09. [Towers](https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/towers) (Also known as Skyscrapers)
|
|
4192
|
+
10. [Singles](https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/singles) (Also known as Hitori)
|
|
4193
|
+
11. [Magnets](https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/magnets)
|
|
4194
|
+
12. [Signpost](https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/signpost)
|
|
4195
|
+
13. [Range](https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/range) (Also known as Kurodoko, Kuromasu, or "Where is Black Cells?")
|
|
4196
|
+
14. [UnDead](https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/undead) (Also known as Haunted or Haunted Mirror Maze)
|
|
4197
|
+
15. [Unruly](https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/unruly) (Also known as "3-In-A-Row")
|
|
4198
|
+
16. [Tracks](https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/tracks)
|
|
4199
|
+
17. [Mosaic](https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/mosaic) (Also known as ArtMosaico, Count and Darken, Cuenta Y Sombrea, Fill-a-Pix, Fill-In, Komsu Karala, Magipic, Majipiku, Mosaico, Mosaik, Mozaiek, Nampre Puzzle, Nurie-Puzzle, Oekaki-Pix, or Voisimage)
|
|
4200
|
+
18. [Map](https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/map)
|
|
4201
|
+
19. [Pearl](https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/pearl) (Also known as Masyu)
|
|
4202
|
+
20. [Bridges](https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/bridges) (Also known as Hashiwokakero)
|
|
4203
|
+
21. [Inertia](https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/inertia)
|
|
4204
|
+
22. [Guess](https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/guess)
|
|
4205
|
+
23. [Chess Range](https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/chess_range)
|
|
4206
|
+
24. [Chess Solo](https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/chess_range)
|
|
4207
|
+
25. [Chess Melee](https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/chess_range)
|
|
4208
|
+
26. [Thermometers](https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/thermometers)
|
|
4209
|
+
27. [Aquarium](https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/aquarium)
|
|
4210
|
+
28. [Stitches](https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/stitches)
|
|
4211
|
+
29. [Battleships](https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/battleships)
|
|
4212
|
+
30. [Kakurasu](https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/kakurasu)
|
|
4213
|
+
31. [Star Battle](https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/star_battle)
|
|
4214
|
+
32. [Star Battle Shapeless](https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/star_battle)
|
|
4215
|
+
33. [Lits](https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/lits)
|
|
4216
|
+
34. [Black Box](https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/black_box)
|
|
4217
|
+
35. [Galaxies](https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/galaxies) (Also known as Tentai Show, Tentaisho, Galaxies, Spiral Galaxies, or Sym-a-Pix)
|
|
4218
|
+
36. [Slant](https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/slant)
|
|
4219
|
+
37. [Unequal](https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/unequal) (Also known as Futoshiki, the Adjacent variant is also known as Renzoku or Neighbours)
|
|
4220
|
+
38. [Norinori](https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/norinori)
|
|
4221
|
+
39. [Slitherlink](https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/slitherlink) (Also known as Fences, Loop the Loop, or Loopy)
|
|
4222
|
+
40. [Yin-Yang](https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/yin_yang)
|
|
4223
|
+
41. [Binairo](https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/binairo) (Also known as Takuzu, Binero, Tohu-Wa-Vohu (Formless and Empty), Eins und Zwei (One and Two), Binary Puzzles, Binoxxo, Binox, Zernero, Tic-Tac-Logic, TicTacToe, or Sudoku Binary)
|
|
4224
|
+
42. [Rectangles](https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/rectangles) (Also known as Shikaku or CellBlocks)
|
|
4225
|
+
43. [Palisade](https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/palisade)
|
|
4226
|
+
44. [Flip](https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/flip)
|
|
4227
|
+
45. [Nurikabe](https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/nurikabe)
|
|
4228
|
+
46. [Heyawake](https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/heyawake)
|
|
4229
|
+
47. [Shingoki](https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/shingoki) (Also known as Semaphores)
|
|
4230
|
+
48. [Tapa](https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/tapa)
|
|
4231
|
+
49. [Binairo Plus](https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/binairo)
|
|
4232
|
+
50. [Shakashaka](https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/shakashaka) (Also known as Proof of Quilt)
|
|
4233
|
+
51. [Kakuro](https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/kakuro)
|
|
4234
|
+
52. [Sudoku Jigsaw](https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/sudoku)
|
|
4235
|
+
53. [Sudoku Killer](https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/sudoku)
|
|
4236
|
+
54. [Flood It](https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/flood_it)
|
|
4237
|
+
55. [Pipes](https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/pipes) (Also known as Net or Network)
|
|
4238
|
+
56. [Connect the Dots](https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/connect_the_dots) (Also known as Numberlink)
|
|
4239
|
+
57. [Nonograms Colored](https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/nonograms) (Also known as Nonogrids, Numbergrids, Picross, Hanjie, Paint by Numbers, Griddlers, or Pic-a-Pix)
|
|
4240
|
+
58. [ABC View](https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/abc_view) (Also known as "Easy as ABC", "ABC End View", or "Last Man Standing")
|
|
4241
|
+
59. [Mathema Grids](https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/mathema_grids) (Also known as SetSquare grid)
|
|
4242
|
+
60. [Split Ends](https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/split_ends)
|
|
4243
|
+
61. [N-Queens](https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/n_queens)
|
|
4244
|
+
62. [Troix](https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/troix)
|
|
4245
|
+
63. [Dumplings](https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/troix)
|
|
4246
|
+
64. [Hidoku](https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/hidoku)
|
|
4247
|
+
65. [Suko](https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/suko)
|
|
4248
|
+
66. [Suguru](https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/suguru)
|
|
4249
|
+
67. [Number Path](https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/number_path)
|
|
4250
|
+
68. [Yajilin](https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/yajilin) (Also known as Yalooniq or Arrow Ring)
|
|
4251
|
+
69. [NumberMaze](https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/numbermaze) (Also known as Dot Stream)
|
|
4252
|
+
70. [Link-a-Pix](https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/link_a_pix)
|
|
4253
|
+
71. [Trees Logic](https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/trees_logic)
|
|
4254
|
+
72. [Vectors](https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/vectors) (Also known as "Four Winds" or "Line Game")
|
|
4255
|
+
73. [Vermicelli](https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/vermicelli)
|
|
4256
|
+
74. [Cow and Cactus](https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/cow_and_cactus)
|
|
4257
|
+
75. [Kropki](https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/kropki)
|
|
4258
|
+
76. [Ripple Effect](https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/ripple_effect) (Also known as Hakyuu)
|
|
4259
|
+
77. [Area 51](https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/area_51)
|
|
4260
|
+
78. [Circle 9](https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/circle_9)
|
|
4261
|
+
79. [Krypto Kakuro](https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/kakuro)
|
|
4262
|
+
80. [Snail](https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/snail)
|
|
4263
|
+
81. [Hidden Stars](https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/hidden_stars)
|
|
4264
|
+
82. [Branches](https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/branches)
|
|
4265
|
+
83. [Tatami](https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/tatami) (Also known as Patchwork)
|
|
4266
|
+
84. [Linesweeper](https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/linesweeper) (Also known as "Loop")
|
|
4267
|
+
85. [Clouds](https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/clouds) (Also known as Rain Clouds or Radar)
|
|
4268
|
+
86. [Walls](https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/walls)
|
|
4269
|
+
87. [Rooms](https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/rooms) (Also known as Seethrough, Doors, or "Open Office")
|
|
4270
|
+
88. [Mathrax](https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/mathrax)
|
|
4271
|
+
|
|
4272
|
+
<!-- AUTO-GENERATED ALIASES END -->
|
|
4273
|
+
|
|
4274
|
+
---
|
|
4275
|
+
|
|
4276
|
+
---
|
|
4277
|
+
|
|
4278
|
+
# Other
|
|
4279
|
+
|
|
4280
|
+
## Why SAT / CP-SAT?
|
|
4281
|
+
|
|
4282
|
+
Because it is extremely faster than naive solutions and many pencil puzzles can be modeled with:
|
|
4283
|
+
|
|
4284
|
+
- **Boolean decisions** (e.g., black/white, place item/not place item)
|
|
4285
|
+
- **Linear constraints** (counts, separations, adjacency)
|
|
4286
|
+
- **All-different / visibility / reachability** constraints
|
|
4287
|
+
|
|
4288
|
+
This repo builds those constraints in Python and uses SAT/CP-SAT (e.g., OR-Tools) to search efficiently. It both demonstrates the modeling and provides usable solvers.
|
|
4289
|
+
|
|
4290
|
+
---
|
|
4291
|
+
|
|
4292
|
+
## Testing
|
|
4293
|
+
|
|
4294
|
+
To run the tests, simply run the following (to create a fresh conda environment and install the dev dependencies):
|
|
4295
|
+
|
|
4296
|
+
```bash
|
|
4297
|
+
conda create -p ./env python=3.11
|
|
4298
|
+
conda activate ./env
|
|
4299
|
+
pip install -r requirements.txt
|
|
4300
|
+
pip install -r ./tests/requirements-dev.txt
|
|
4301
|
+
pytest
|
|
4302
|
+
```
|
|
4303
|
+
|
|
4304
|
+
the `pytest.ini` file is used to configure the pytest command to use `-n 4` to have 4 workers.
|
|
4305
|
+
|
|
4306
|
+
## Contributing
|
|
4307
|
+
|
|
4308
|
+
Issues and PRs welcome!
|
|
4309
|
+
|
|
4310
|
+
|
|
4311
|
+
* Python version `>= 3.9` required.
|
|
4312
|
+
* Keep puzzle folders self-contained (solver, README.md, other files if needed).
|
|
4313
|
+
* Prefer small, readable encodings with comments explaining each constraint.
|
|
4314
|
+
* If you add a new puzzle:
|
|
4315
|
+
|
|
4316
|
+
1. Create a directory in `src/puzzle_solver/puzzles/<name>/`,
|
|
4317
|
+
2. Add a minimal test script in `tests/test_<name>.py`,
|
|
4318
|
+
3. Document the modeling in code comments,
|
|
4319
|
+
|
|
4320
|
+
### Build and push to PyPI
|
|
4321
|
+
|
|
4322
|
+
1. First make sure all the tests pass (see [Testing](#testing))
|
|
4323
|
+
2. Update the version in `src/puzzle_solver/__init__.py`
|
|
4324
|
+
3. Build and push:
|
|
4325
|
+
1. Bash: `./scripts/build.sh`
|
|
4326
|
+
2. Powershell: `./scripts/build.ps1`
|