multi-puzzle-solver 0.9.30__py3-none-any.whl → 1.0.2__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.
Potentially problematic release.
This version of multi-puzzle-solver might be problematic. Click here for more details.
- {multi_puzzle_solver-0.9.30.dist-info → multi_puzzle_solver-1.0.2.dist-info}/METADATA +331 -76
- multi_puzzle_solver-1.0.2.dist-info/RECORD +69 -0
- puzzle_solver/__init__.py +58 -1
- puzzle_solver/core/utils_ortools.py +8 -6
- puzzle_solver/core/utils_visualizer.py +23 -41
- puzzle_solver/puzzles/binairo/binairo.py +4 -4
- puzzle_solver/puzzles/black_box/black_box.py +5 -11
- puzzle_solver/puzzles/bridges/bridges.py +1 -1
- puzzle_solver/puzzles/chess_range/chess_range.py +3 -3
- puzzle_solver/puzzles/chess_range/chess_solo.py +1 -1
- puzzle_solver/puzzles/filling/filling.py +3 -3
- puzzle_solver/puzzles/flood_it/flood_it.py +174 -0
- puzzle_solver/puzzles/flood_it/parse_map/parse_map.py +198 -0
- puzzle_solver/puzzles/galaxies/galaxies.py +1 -1
- puzzle_solver/puzzles/galaxies/parse_map/parse_map.py +3 -3
- puzzle_solver/puzzles/guess/guess.py +1 -1
- puzzle_solver/puzzles/heyawake/heyawake.py +3 -3
- puzzle_solver/puzzles/inertia/inertia.py +1 -1
- puzzle_solver/puzzles/inertia/parse_map/parse_map.py +13 -10
- puzzle_solver/puzzles/inertia/tsp.py +5 -7
- puzzle_solver/puzzles/kakuro/kakuro.py +1 -1
- puzzle_solver/puzzles/keen/keen.py +2 -2
- puzzle_solver/puzzles/minesweeper/minesweeper.py +2 -3
- puzzle_solver/puzzles/nonograms/nonograms.py +3 -3
- puzzle_solver/puzzles/norinori/norinori.py +2 -2
- puzzle_solver/puzzles/nurikabe/nurikabe.py +2 -2
- puzzle_solver/puzzles/range/range.py +1 -1
- puzzle_solver/puzzles/rectangles/rectangles.py +2 -6
- puzzle_solver/puzzles/shingoki/shingoki.py +1 -1
- puzzle_solver/puzzles/signpost/signpost.py +2 -2
- puzzle_solver/puzzles/slant/parse_map/parse_map.py +7 -5
- puzzle_solver/puzzles/slitherlink/slitherlink.py +1 -1
- puzzle_solver/puzzles/stitches/parse_map/parse_map.py +6 -5
- puzzle_solver/puzzles/stitches/stitches.py +1 -1
- puzzle_solver/puzzles/sudoku/sudoku.py +91 -20
- puzzle_solver/puzzles/tents/tents.py +2 -2
- puzzle_solver/puzzles/thermometers/thermometers.py +1 -1
- puzzle_solver/puzzles/towers/towers.py +1 -1
- puzzle_solver/puzzles/undead/undead.py +1 -1
- puzzle_solver/puzzles/unruly/unruly.py +1 -1
- puzzle_solver/puzzles/yin_yang/yin_yang.py +1 -1
- puzzle_solver/utils/visualizer.py +1 -1
- multi_puzzle_solver-0.9.30.dist-info/RECORD +0 -67
- {multi_puzzle_solver-0.9.30.dist-info → multi_puzzle_solver-1.0.2.dist-info}/WHEEL +0 -0
- {multi_puzzle_solver-0.9.30.dist-info → multi_puzzle_solver-1.0.2.dist-info}/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: multi-puzzle-solver
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 1.0.2
|
|
4
4
|
Summary: Efficient solvers for numerous popular and esoteric logic puzzles using CP-SAT
|
|
5
5
|
Author: Ar-Kareem
|
|
6
6
|
Project-URL: Homepage, https://github.com/Ar-Kareem/puzzle_solver
|
|
@@ -369,6 +369,28 @@ These are all the puzzles that are implemented in this repo. <br> Click on any o
|
|
|
369
369
|
</a>
|
|
370
370
|
</td>
|
|
371
371
|
</tr>
|
|
372
|
+
<tr>
|
|
373
|
+
<td align="center">
|
|
374
|
+
<a href="#kakuro-puzzle-type-51"><b>Kakuro</b><br><br>
|
|
375
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/kakuro_solved.png" alt="Kakuro" width="140">
|
|
376
|
+
</a>
|
|
377
|
+
</td>
|
|
378
|
+
<td align="center">
|
|
379
|
+
<a href="#sudoku-jigsaw-puzzle-type-52"><b>Sudoku Jigsaw</b><br><br>
|
|
380
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/sudoku_jigsaw_solved.png" alt="Sudoku Jigsaw" width="140">
|
|
381
|
+
</a>
|
|
382
|
+
</td>
|
|
383
|
+
<td align="center">
|
|
384
|
+
<a href="#sudoku-killer-puzzle-type-53"><b>Sudoku Killer</b><br><br>
|
|
385
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/sudoku_killer_solved.png" alt="Sudoku Killer" width="140">
|
|
386
|
+
</a>
|
|
387
|
+
</td>
|
|
388
|
+
<td align="center">
|
|
389
|
+
<a href="#flood-it-puzzle-type-54"><b>Flood It</b><br><br>
|
|
390
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/flood_it_unsolved.png" alt="Flood It" width="140">
|
|
391
|
+
</a>
|
|
392
|
+
</td>
|
|
393
|
+
</tr>
|
|
372
394
|
</table>
|
|
373
395
|
|
|
374
396
|
</div>
|
|
@@ -434,6 +456,9 @@ These are all the puzzles that are implemented in this repo. <br> Click on any o
|
|
|
434
456
|
- [Binairo Plus (Puzzle Type #49)](#binairo-plus-puzzle-type-49)
|
|
435
457
|
- [Shakashaka (Puzzle Type #50)](#shakashaka-puzzle-type-50)
|
|
436
458
|
- [Kakuro (Puzzle Type #51)](#kakuro-puzzle-type-51)
|
|
459
|
+
- [Sudoku Jigsaw (Puzzle Type #52)](#sudoku-jigsaw-puzzle-type-52)
|
|
460
|
+
- [Sudoku Killer (Puzzle Type #53)](#sudoku-killer-puzzle-type-53)
|
|
461
|
+
- [Flood It (Puzzle Type #54)](#flood-it-puzzle-type-54)
|
|
437
462
|
- [Why SAT / CP-SAT?](#why-sat--cp-sat)
|
|
438
463
|
- [Testing](#testing)
|
|
439
464
|
- [Contributing](#contributing)
|
|
@@ -4631,108 +4656,109 @@ solutions = binst.solve_and_print()
|
|
|
4631
4656
|
```python
|
|
4632
4657
|
Solution found
|
|
4633
4658
|
┌──────┬──────┬──────┬──────┬──────┬──────┬──────┬──────┬──────┬──────┬──────┬──────┬──────┬──────┬──────┬──────┬──────┬──────┬──────┬──────┬──────┬──────┬──────┬──────┬──────┐
|
|
4634
|
-
│
|
|
4635
|
-
│
|
|
4659
|
+
│ /█│█\ │ │██████│ │ /█│█\ │ │██████│██████│ │ │██████│ /█│█\ │ │██████│ /█│█\ │██████│ │██████│ │ /█│█\ │
|
|
4660
|
+
│ /███│███\ │ . │██████│ 1 │ /███│███\ │ 1 │██████│██████│ . │ . │██████│ /███│███\ │ 2 │██████│ /███│███\ │██████│ . │██████│ . │ /███│███\ │
|
|
4636
4661
|
│/█████│█████\│ │██████│ │/█████│█████\│ │██████│██████│ │ │██████│/█████│█████\│ │██████│/█████│█████\│██████│ │██████│ │/█████│█████\│
|
|
4637
4662
|
├──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┤
|
|
4638
|
-
│\█████│█████/│
|
|
4639
|
-
│
|
|
4640
|
-
│
|
|
4663
|
+
│\█████│█████/│ /█│█\ │██████│\█████│█████/│██████│ /█│█\ │██████│ │██████│\█████│██████│█\ │ │\█████│██████│█\ │██████│ /█│█\ │\█████│█████/│
|
|
4664
|
+
│ \███│███/ │ /███│███\ │██████│ \███│███/ │██████│ /███│███\ │██████│ . │██████│ \███│██████│███\ │ . │ \███│██████│███\ │██████│ /███│███\ │ \███│███/ │
|
|
4665
|
+
│ \█│█/ │/█████│█████\│██████│ \█│█/ │██████│/█████│█████\│██████│ │██████│ \█│██████│█████\│ │ \█│██████│█████\│██████│/█████│█████\│ \█│█/ │
|
|
4641
4666
|
├──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┤
|
|
4642
|
-
│██████│
|
|
4643
|
-
│██████│
|
|
4644
|
-
│██████│/█████│██████│██████│█████\│/█████│█████\│ │
|
|
4667
|
+
│██████│ /█│██████│██████│█\ │ /█│█\ │ │\█████│██████│█\ │██████│ /█│█\ │\█████│██████│█\ │ │\█████│█████/│ /█│██████│██████│█\ │██████│
|
|
4668
|
+
│██████│ /███│██████│██████│███\ │ /███│███\ │ 3 │ \███│██████│███\ │██████│ /███│███\ │ \███│██████│███\ │ 4 │ \███│███/ │ /███│██████│██████│███\ │██████│
|
|
4669
|
+
│██████│/█████│██████│██████│█████\│/█████│█████\│ │ \█│██████│█████\│██████│/█████│█████\│ \█│██████│█████\│ │ \█│█/ │/█████│██████│██████│█████\│██████│
|
|
4645
4670
|
├──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┤
|
|
4646
|
-
│██████│\█████│██████│██████│█████/│\█████│█████/│
|
|
4647
|
-
│██████│
|
|
4648
|
-
│██████│
|
|
4671
|
+
│██████│\█████│██████│██████│█████/│\█████│█████/│ /█│█\ │\█████│█████/│ │\█████│█████/│██████│\█████│██████│█\ │ │██████│\█████│██████│██████│█████/│ │
|
|
4672
|
+
│██████│ \███│██████│██████│███/ │ \███│███/ │ /███│███\ │ \███│███/ │ . │ \███│███/ │██████│ \███│██████│███\ │ 3 │██████│ \███│██████│██████│███/ │ . │
|
|
4673
|
+
│██████│ \█│██████│██████│█/ │ \█│█/ │/█████│█████\│ \█│█/ │ │ \█│█/ │██████│ \█│██████│█████\│ │██████│ \█│██████│██████│█/ │ │
|
|
4649
4674
|
├──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┤
|
|
4650
|
-
│ │██████│\█████│█████/│
|
|
4651
|
-
│
|
|
4652
|
-
│ │██████│
|
|
4675
|
+
│ │██████│\█████│█████/│ /█│█\ │ /█│██████│█████/│██████│ │ /█│█\ │ /█│█\ │██████│\█████│█████/│ /█│█\ │ │\█████│█████/│██████│██████│
|
|
4676
|
+
│ 1 │██████│ \███│███/ │ /███│███\ │ /███│██████│███/ │██████│ 2 │ /███│███\ │ /███│███\ │██████│ \███│███/ │ /███│███\ │ 4 │ \███│███/ │██████│██████│
|
|
4677
|
+
│ │██████│ \█│█/ │/█████│█████\│/█████│██████│█/ │██████│ │/█████│█████\│/█████│█████\│██████│ \█│█/ │/█████│█████\│ │ \█│█/ │██████│██████│
|
|
4653
4678
|
├──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┤
|
|
4654
|
-
│
|
|
4655
|
-
│
|
|
4656
|
-
│/█████│█████\│ │██████│
|
|
4679
|
+
│ /█│█\ │ │██████│\█████│█████/│\█████│█████/│ /█│█\ │██████│\█████│█████/│\█████│█████/│ /█│█\ │██████│\█████│█████/│ /█│█\ │ │ /█│█\ │
|
|
4680
|
+
│ /███│███\ │ 3 │██████│ \███│███/ │ \███│███/ │ /███│███\ │██████│ \███│███/ │ \███│███/ │ /███│███\ │██████│ \███│███/ │ /███│███\ │ . │ /███│███\ │
|
|
4681
|
+
│/█████│█████\│ │██████│ \█│█/ │ \█│█/ │/█████│█████\│██████│ \█│█/ │ \█│█/ │/█████│█████\│██████│ \█│█/ │/█████│█████\│ │/█████│█████\│
|
|
4657
4682
|
├──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┤
|
|
4658
|
-
|
|
4659
|
-
│
|
|
4660
|
-
│
|
|
4683
|
+
│\█████│██████│█\ │ │██████│██████│ │ /█│██████│██████│█\ │ │██████│ │ /█│██████│█████/│ │ /█│█\ │\█████│██████│█\ │\█████│█████/│
|
|
4684
|
+
│ \███│██████│███\ │ 1 │██████│██████│ 2 │ /███│██████│██████│███\ │ . │██████│ 3 │ /███│██████│███/ │ . │ /███│███\ │ \███│██████│███\ │ \███│███/ │
|
|
4685
|
+
│ \█│██████│█████\│ │██████│██████│ │/█████│██████│██████│█████\│ │██████│ │/█████│██████│█/ │ │/█████│█████\│ \█│██████│█████\│ \█│█/ │
|
|
4661
4686
|
├──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┤
|
|
4662
|
-
│██████│\█████│█████/│ │██████│██████│ │\█████│██████│██████│█████/│██████│
|
|
4663
|
-
│██████│
|
|
4664
|
-
│██████│
|
|
4687
|
+
│██████│\█████│█████/│ │██████│██████│ │\█████│██████│██████│█████/│██████│ /█│█\ │\█████│█████/│ │██████│\█████│█████/│ │\█████│█████/│██████│ │
|
|
4688
|
+
│██████│ \███│███/ │ . │██████│██████│ . │ \███│██████│██████│███/ │██████│ /███│███\ │ \███│███/ │ 3 │██████│ \███│███/ │ 4 │ \███│███/ │██████│ . │
|
|
4689
|
+
│██████│ \█│█/ │ │██████│██████│ │ \█│██████│██████│█/ │██████│/█████│█████\│ \█│█/ │ │██████│ \█│█/ │ │ \█│█/ │██████│ │
|
|
4665
4690
|
├──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┤
|
|
4666
|
-
│██████│ │ │
|
|
4667
|
-
│██████│
|
|
4668
|
-
│██████│ │ │/█████│█████\│ │██████│██████│
|
|
4691
|
+
│██████│ │ │ /█│█\ │ │██████│██████│\█████│█████/│ │ /█│██████│█████/│ │██████│ /█│█\ │ /█│█\ │ /█│█\ │ │ /█│█\ │
|
|
4692
|
+
│██████│ . │ 2 │ /███│███\ │ . │██████│██████│ \███│███/ │ 3 │ /███│██████│███/ │ 2 │██████│ /███│███\ │ /███│███\ │ /███│███\ │ 4 │ /███│███\ │
|
|
4693
|
+
│██████│ │ │/█████│█████\│ │██████│██████│ \█│█/ │ │/█████│██████│█/ │ │██████│/█████│█████\│/█████│█████\│/█████│█████\│ │/█████│█████\│
|
|
4669
4694
|
├──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┤
|
|
4670
|
-
│ │██████│██████│\█████│█████/│ │██████│██████│ │██████│██████│\█████│█████/│██████│██████│
|
|
4671
|
-
│
|
|
4672
|
-
│ │██████│██████│
|
|
4695
|
+
│ │██████│██████│\█████│█████/│ │██████│██████│ │██████│██████│\█████│█████/│██████│██████│ /█│██████│█████/│\█████│█████/│\█████│█████/│ /█│██████│█████/│
|
|
4696
|
+
│ . │██████│██████│ \███│███/ │ . │██████│██████│ 1 │██████│██████│ \███│███/ │██████│██████│ /███│██████│███/ │ \███│███/ │ \███│███/ │ /███│██████│███/ │
|
|
4697
|
+
│ │██████│██████│ \█│█/ │ │██████│██████│ │██████│██████│ \█│█/ │██████│██████│/█████│██████│█/ │ \█│█/ │ \█│█/ │/█████│██████│█/ │
|
|
4673
4698
|
├──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┤
|
|
4674
|
-
│ │██████│██████│ │
|
|
4675
|
-
│
|
|
4676
|
-
│ │██████│██████│ │/█████│█████\│██████│██████│ │/█████│█████\│██████│ │ │ │
|
|
4699
|
+
│ │██████│██████│ │ /█│█\ │██████│██████│ │ /█│█\ │██████│ │ │ │\█████│█████/│ /█│█\ │ │██████│ /█│██████│█████/│ │
|
|
4700
|
+
│ 0 │██████│██████│ . │ /███│███\ │██████│██████│ . │ /███│███\ │██████│ . │ . │ . │ \███│███/ │ /███│███\ │ 3 │██████│ /███│██████│███/ │ . │
|
|
4701
|
+
│ │██████│██████│ │/█████│█████\│██████│██████│ │/█████│█████\│██████│ │ │ │ \█│█/ │/█████│█████\│ │██████│/█████│██████│█/ │ │
|
|
4677
4702
|
├──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┤
|
|
4678
|
-
│ │██████│██████│
|
|
4679
|
-
│
|
|
4680
|
-
│ │██████│██████│ │
|
|
4703
|
+
│ │██████│██████│ │\█████│██████│█\ │ │ /█│██████│█████/│ │██████│ /█│█\ │██████│ /█│██████│██████│█\ │██████│\█████│█████/│ │██████│
|
|
4704
|
+
│ 0 │██████│██████│ . │ \███│██████│███\ │ . │ /███│██████│███/ │ 1 │██████│ /███│███\ │██████│ /███│██████│██████│███\ │██████│ \███│███/ │ 3 │██████│
|
|
4705
|
+
│ │██████│██████│ │ \█│██████│█████\│ │/█████│██████│█/ │ │██████│/█████│█████\│██████│/█████│██████│██████│█████\│██████│ \█│█/ │ │██████│
|
|
4681
4706
|
├──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┤
|
|
4682
|
-
│██████│
|
|
4683
|
-
│██████│
|
|
4684
|
-
│██████│/█████│█████\│/█████│█████\│
|
|
4707
|
+
│██████│ /█│█\ │ /█│█\ │\█████│██████│█\ │\█████│█████/│ │██████│ │\█████│█████/│ │\█████│██████│██████│██████│█\ │ │ /█│█\ │██████│
|
|
4708
|
+
│██████│ /███│███\ │ /███│███\ │ \███│██████│███\ │ \███│███/ │ 2 │██████│ . │ \███│███/ │ . │ \███│██████│██████│██████│███\ │ . │ /███│███\ │██████│
|
|
4709
|
+
│██████│/█████│█████\│/█████│█████\│ \█│██████│█████\│ \█│█/ │ │██████│ │ \█│█/ │ │ \█│██████│██████│██████│█████\│ │/█████│█████\│██████│
|
|
4685
4710
|
├──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┤
|
|
4686
|
-
│
|
|
4687
|
-
│
|
|
4688
|
-
|
|
4711
|
+
│ /█│██████│█████/│\█████│█████/│ │\█████│█████/│ │██████│ │██████│ │██████│ │ /█│█\ │\█████│██████│██████│█████/│██████│\█████│██████│█\ │
|
|
4712
|
+
│ /███│██████│███/ │ \███│███/ │ . │ \███│███/ │ . │██████│ . │██████│ . │██████│ . │ /███│███\ │ \███│██████│██████│███/ │██████│ \███│██████│███\ │
|
|
4713
|
+
│/█████│██████│█/ │ \█│█/ │ │ \█│█/ │ │██████│ │██████│ │██████│ │/█████│█████\│ \█│██████│██████│█/ │██████│ \█│██████│█████\│
|
|
4689
4714
|
├──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┤
|
|
4690
|
-
│\█████│█████/│
|
|
4691
|
-
│
|
|
4692
|
-
│
|
|
4715
|
+
│\█████│█████/│ /█│█\ │ │ /█│█\ │ │██████│ │██████│ /█│█\ │ /█│█\ │\█████│█████/│ │\█████│█████/│ │ /█│█\ │\█████│█████/│
|
|
4716
|
+
│ \███│███/ │ /███│███\ │ 4 │ /███│███\ │ 3 │██████│ . │██████│ /███│███\ │ /███│███\ │ \███│███/ │ . │ \███│███/ │ 4 │ /███│███\ │ \███│███/ │
|
|
4717
|
+
│ \█│█/ │/█████│█████\│ │/█████│█████\│ │██████│ │██████│/█████│█████\│/█████│█████\│ \█│█/ │ │ \█│█/ │ │/█████│█████\│ \█│█/ │
|
|
4693
4718
|
├──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┤
|
|
4694
|
-
│██████│
|
|
4695
|
-
│██████│
|
|
4696
|
-
│██████│ │
|
|
4719
|
+
│██████│ │\█████│██████│█\ │\█████│█████/│ /█│█\ │██████│ │\█████│█████/│\█████│█████/│ │ /█│█\ │ │ /█│█\ │\█████│██████│█\ │ │
|
|
4720
|
+
│██████│ . │ \███│██████│███\ │ \███│███/ │ /███│███\ │██████│ . │ \███│███/ │ \███│███/ │ 3 │ /███│███\ │ . │ /███│███\ │ \███│██████│███\ │ 3 │
|
|
4721
|
+
│██████│ │ \█│██████│█████\│ \█│█/ │/█████│█████\│██████│ │ \█│█/ │ \█│█/ │ │/█████│█████\│ │/█████│█████\│ \█│██████│█████\│ │
|
|
4697
4722
|
├──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┤
|
|
4698
|
-
│ │██████│██████│\█████│█████/│██████│██████│\█████│█████/│ │
|
|
4699
|
-
│
|
|
4700
|
-
│ │██████│██████│
|
|
4723
|
+
│ │██████│██████│\█████│█████/│██████│██████│\█████│█████/│ │ /█│█\ │██████│ │██████│██████│\█████│██████│█\ │\█████│█████/│ │\█████│██████│█\ │
|
|
4724
|
+
│ . │██████│██████│ \███│███/ │██████│██████│ \███│███/ │ . │ /███│███\ │██████│ 1 │██████│██████│ \███│██████│███\ │ \███│███/ │ 4 │ \███│██████│███\ │
|
|
4725
|
+
│ │██████│██████│ \█│█/ │██████│██████│ \█│█/ │ │/█████│█████\│██████│ │██████│██████│ \█│██████│█████\│ \█│█/ │ │ \█│██████│█████\│
|
|
4701
4726
|
├──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┤
|
|
4702
|
-
│
|
|
4703
|
-
│
|
|
4704
|
-
│/█████│█████\│ │██████│ │██████│██████│ │██████│/█████│██████│██████│█████\│ │██████│██████│ │
|
|
4727
|
+
│ /█│█\ │ │██████│ │██████│██████│ │██████│ /█│██████│██████│█\ │ │██████│██████│ │\█████│█████/│ │ /█│█\ │██████│\█████│█████/│
|
|
4728
|
+
│ /███│███\ │ . │██████│ . │██████│██████│ 2 │██████│ /███│██████│██████│███\ │ . │██████│██████│ . │ \███│███/ │ . │ /███│███\ │██████│ \███│███/ │
|
|
4729
|
+
│/█████│█████\│ │██████│ │██████│██████│ │██████│/█████│██████│██████│█████\│ │██████│██████│ │ \█│█/ │ │/█████│█████\│██████│ \█│█/ │
|
|
4705
4730
|
├──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┤
|
|
4706
|
-
│\█████│█████/│██████│
|
|
4707
|
-
│
|
|
4708
|
-
│
|
|
4731
|
+
│\█████│█████/│██████│ /█│█\ │██████│██████│ /█│█\ │\█████│██████│██████│██████│█\ │██████│██████│ │██████│ /█│█\ │\█████│█████/│ │ /█│█\ │
|
|
4732
|
+
│ \███│███/ │██████│ /███│███\ │██████│██████│ /███│███\ │ \███│██████│██████│██████│███\ │██████│██████│ 0 │██████│ /███│███\ │ \███│███/ │ . │ /███│███\ │
|
|
4733
|
+
│ \█│█/ │██████│/█████│█████\│██████│██████│/█████│█████\│ \█│██████│██████│██████│█████\│██████│██████│ │██████│/█████│█████\│ \█│█/ │ │/█████│█████\│
|
|
4709
4734
|
├──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┤
|
|
4710
|
-
│ │██████│
|
|
4711
|
-
│
|
|
4712
|
-
│
|
|
4735
|
+
│ │██████│ /█│██████│█████/│██████│██████│\█████│█████/│ │\█████│██████│██████│█████/│██████│██████│ │ /█│██████│█████/│██████│██████│██████│\█████│█████/│
|
|
4736
|
+
│ . │██████│ /███│██████│███/ │██████│██████│ \███│███/ │ . │ \███│██████│██████│███/ │██████│██████│ . │ /███│██████│███/ │██████│██████│██████│ \███│███/ │
|
|
4737
|
+
│ │██████│/█████│██████│█/ │██████│██████│ \█│█/ │ │ \█│██████│██████│█/ │██████│██████│ │/█████│██████│█/ │██████│██████│██████│ \█│█/ │
|
|
4713
4738
|
├──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┤
|
|
4714
|
-
│██████│
|
|
4715
|
-
│██████│
|
|
4716
|
-
|
|
4739
|
+
│██████│ /█│██████│█████/│ /█│█\ │ │ │██████│██████│ │\█████│█████/│ /█│█\ │ │ /█│██████│█████/│██████│ │ /█│█\ │ /█│█\ │
|
|
4740
|
+
│██████│ /███│██████│███/ │ /███│███\ │ 2 │ . │██████│██████│ 2 │ \███│███/ │ /███│███\ │ . │ /███│██████│███/ │██████│ 1 │ /███│███\ │ /███│███\ │
|
|
4741
|
+
│██████│/█████│██████│█/ │/█████│█████\│ │ │██████│██████│ │ \█│█/ │/█████│█████\│ │/█████│██████│█/ │██████│ │/█████│█████\│/█████│█████\│
|
|
4717
4742
|
├──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┤
|
|
4718
|
-
│
|
|
4719
|
-
│
|
|
4720
|
-
|
|
4743
|
+
│ /█│██████│█████/│ │\█████│██████│█\ │ │██████│██████│ │ /█│█\ │\█████│█████/│██████│\█████│█████/│ │██████│ │\█████│█████/│\█████│█████/│
|
|
4744
|
+
│ /███│██████│███/ │ 3 │ \███│██████│███\ │ 2 │██████│██████│ 1 │ /███│███\ │ \███│███/ │██████│ \███│███/ │ . │██████│ . │ \███│███/ │ \███│███/ │
|
|
4745
|
+
│/█████│██████│█/ │ │ \█│██████│█████\│ │██████│██████│ │/█████│█████\│ \█│█/ │██████│ \█│█/ │ │██████│ │ \█│█/ │ \█│█/ │
|
|
4721
4746
|
├──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┤
|
|
4722
|
-
│\█████│█████/│
|
|
4723
|
-
│
|
|
4724
|
-
│
|
|
4747
|
+
│\█████│█████/│ │██████│██████│\█████│██████│█\ │██████│██████│ │\█████│██████│█\ │ │ /█│█\ │ │ /█│█\ │██████│██████│ /█│█\ │ │
|
|
4748
|
+
│ \███│███/ │ . │██████│██████│ \███│██████│███\ │██████│██████│ . │ \███│██████│███\ │ . │ /███│███\ │ . │ /███│███\ │██████│██████│ /███│███\ │ 2 │
|
|
4749
|
+
│ \█│█/ │ │██████│██████│ \█│██████│█████\│██████│██████│ │ \█│██████│█████\│ │/█████│█████\│ │/█████│█████\│██████│██████│/█████│█████\│ │
|
|
4725
4750
|
├──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┤
|
|
4726
|
-
│ │
|
|
4727
|
-
│
|
|
4728
|
-
│ │/█████│█████\│ │/█████│█████\│
|
|
4751
|
+
│ │ /█│█\ │ │ /█│█\ │\█████│██████│█\ │ /█│█\ │ │\█████│██████│█\ │\█████│█████/│██████│\█████│█████/│ │ /█│██████│█████/│██████│
|
|
4752
|
+
│ 2 │ /███│███\ │ . │ /███│███\ │ \███│██████│███\ │ /███│███\ │ 3 │ \███│██████│███\ │ \███│███/ │██████│ \███│███/ │ . │ /███│██████│███/ │██████│
|
|
4753
|
+
│ │/█████│█████\│ │/█████│█████\│ \█│██████│█████\│/█████│█████\│ │ \█│██████│█████\│ \█│█/ │██████│ \█│█/ │ │/█████│██████│█/ │██████│
|
|
4729
4754
|
├──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┤
|
|
4730
4755
|
│██████│\█████│█████/│██████│\█████│█████/│ │\█████│█████/│\█████│█████/│██████│ │\█████│█████/│██████│██████│ │██████│██████│██████│\█████│█████/│ │██████│
|
|
4731
|
-
│██████│
|
|
4732
|
-
│██████│
|
|
4733
|
-
└──────┴──────┴──────┴──────┴──────┴──────┴──────┴──────┴──────┴──────┴──────┴──────┴──────┴──────┴──────┴──────┴──────┴──────┴──────┴──────┴──────┴──────┴──────┴──────┴──────┘
|
|
4756
|
+
│██████│ \███│███/ │██████│ \███│███/ │ 3 │ \███│███/ │ \███│███/ │██████│ 2 │ \███│███/ │██████│██████│ 0 │██████│██████│██████│ \███│███/ │ 2 │██████│
|
|
4757
|
+
│██████│ \█│█/ │██████│ \█│█/ │ │ \█│█/ │ \█│█/ │██████│ │ \█│█/ │██████│██████│ │██████│██████│██████│ \█│█/ │ │██████│
|
|
4758
|
+
└──────┴──────┴──────┴──────┴──────┴──────┴──────┴──────┴──────┴──────┴──────┴──────┴──────┴──────┴──────┴──────┴──────┴──────┴──────┴──────┴──────┴──────┴──────┴──────┴──────┘
|
|
4759
|
+
Solutions found: 1
|
|
4734
4760
|
status: OPTIMAL
|
|
4735
|
-
Time taken: 0.
|
|
4761
|
+
Time taken: 0.36 seconds
|
|
4736
4762
|
```
|
|
4737
4763
|
|
|
4738
4764
|
**Solved puzzle**
|
|
@@ -4822,6 +4848,232 @@ Time taken: 0.00 seconds
|
|
|
4822
4848
|
|
|
4823
4849
|
---
|
|
4824
4850
|
|
|
4851
|
+
## Sudoku Jigsaw (Puzzle Type #52)
|
|
4852
|
+
|
|
4853
|
+
* [**Play online**](https://www.puzzle-jigsaw-sudoku.com/)
|
|
4854
|
+
|
|
4855
|
+
* [**Solver Code**][52]
|
|
4856
|
+
|
|
4857
|
+
<details>
|
|
4858
|
+
<summary><strong>Rules</strong></summary>
|
|
4859
|
+
|
|
4860
|
+
1. The basic Sudoku rules apply.
|
|
4861
|
+
2. The difference is that instead of having 3x3 rectangular blocks these blocks have irregular shapes
|
|
4862
|
+
|
|
4863
|
+
</details>
|
|
4864
|
+
|
|
4865
|
+
**Unsolved puzzle**
|
|
4866
|
+
|
|
4867
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/sudoku_jigsaw_unsolved.png" alt="Sudoku Jigsaw unsolved" width="500">
|
|
4868
|
+
|
|
4869
|
+
Code to utilize this package and solve the puzzle:
|
|
4870
|
+
|
|
4871
|
+
(Note: the ids are arbitrary and simply represent cells that share a block)
|
|
4872
|
+
|
|
4873
|
+
```python
|
|
4874
|
+
import numpy as np
|
|
4875
|
+
from puzzle_solver import sudoku_solver as solver
|
|
4876
|
+
board = np.array([
|
|
4877
|
+
[ '1', ' ', ' ', '2', ' ', ' ', '8', '5', ' ' ],
|
|
4878
|
+
[ '2', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' ],
|
|
4879
|
+
[ ' ', ' ', '8', ' ', ' ', ' ', ' ', ' ', ' ' ],
|
|
4880
|
+
[ '7', ' ', ' ', '5', ' ', '1', ' ', ' ', ' ' ],
|
|
4881
|
+
[ ' ', ' ', ' ', '1', ' ', '3', ' ', ' ', ' ' ],
|
|
4882
|
+
[ ' ', ' ', ' ', '8', ' ', '4', ' ', ' ', '6' ],
|
|
4883
|
+
[ ' ', ' ', ' ', ' ', ' ', ' ', '5', ' ', ' ' ],
|
|
4884
|
+
[ ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '5' ],
|
|
4885
|
+
[ ' ', '2', '6', ' ', ' ', '9', ' ', ' ', '1' ],
|
|
4886
|
+
])
|
|
4887
|
+
jigsaw_ids = np.array([
|
|
4888
|
+
['00', '00', '01', '01', '01', '01', '02', '02', '02'],
|
|
4889
|
+
['00', '00', '01', '01', '03', '01', '01', '02', '02'],
|
|
4890
|
+
['00', '00', '01', '04', '03', '03', '02', '02', '02'],
|
|
4891
|
+
['00', '04', '04', '04', '03', '03', '03', '03', '02'],
|
|
4892
|
+
['00', '00', '04', '04', '03', '03', '05', '05', '05'],
|
|
4893
|
+
['06', '04', '04', '04', '05', '05', '05', '07', '05'],
|
|
4894
|
+
['06', '08', '08', '08', '08', '05', '05', '07', '07'],
|
|
4895
|
+
['06', '06', '06', '06', '08', '07', '07', '07', '07'],
|
|
4896
|
+
['06', '06', '06', '08', '08', '08', '08', '07', '07'],
|
|
4897
|
+
])
|
|
4898
|
+
binst = solver.Board(board=board, jigsaw=jigsaw_ids, constrain_blocks=False)
|
|
4899
|
+
solutions = binst.solve_and_print()
|
|
4900
|
+
```
|
|
4901
|
+
|
|
4902
|
+
**Script Output**
|
|
4903
|
+
|
|
4904
|
+
```python
|
|
4905
|
+
Solution found
|
|
4906
|
+
[['1' '9' '4' '2' '3' '6' '8' '5' '7']
|
|
4907
|
+
['2' '8' '5' '9' '4' '7' '1' '6' '3']
|
|
4908
|
+
['6' '3' '8' '4' '7' '5' '9' '1' '2']
|
|
4909
|
+
['7' '6' '3' '5' '9' '1' '2' '8' '4']
|
|
4910
|
+
['4' '5' '2' '1' '6' '3' '7' '9' '8']
|
|
4911
|
+
['5' '7' '9' '8' '1' '4' '3' '2' '6']
|
|
4912
|
+
['3' '1' '7' '6' '8' '2' '5' '4' '9']
|
|
4913
|
+
['9' '4' '1' '7' '2' '8' '6' '3' '5']
|
|
4914
|
+
['8' '2' '6' '3' '5' '9' '4' '7' '1']]
|
|
4915
|
+
Solutions found: 1
|
|
4916
|
+
status: OPTIMAL
|
|
4917
|
+
Time taken: 0.01 seconds
|
|
4918
|
+
```
|
|
4919
|
+
|
|
4920
|
+
**Solved puzzle**
|
|
4921
|
+
|
|
4922
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/sudoku_jigsaw_solved.png" alt="Sudoku Jigsaw solved" width="500">
|
|
4923
|
+
|
|
4924
|
+
---
|
|
4925
|
+
|
|
4926
|
+
## Sudoku Killer (Puzzle Type #53)
|
|
4927
|
+
|
|
4928
|
+
* [**Play online**](https://www.puzzle-killer-sudoku.com/)
|
|
4929
|
+
|
|
4930
|
+
* [**Solver Code**][53]
|
|
4931
|
+
|
|
4932
|
+
<details>
|
|
4933
|
+
<summary><strong>Rules</strong></summary>
|
|
4934
|
+
|
|
4935
|
+
1. The basic Sudoku rules apply.
|
|
4936
|
+
2. The sum of all numbers in a cage must match the small number printed in its corner.
|
|
4937
|
+
3. No number appears more than once in a cage.
|
|
4938
|
+
|
|
4939
|
+
</details>
|
|
4940
|
+
|
|
4941
|
+
**Unsolved puzzle**
|
|
4942
|
+
|
|
4943
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/sudoku_killer_unsolved.png" alt="Sudoku Killer unsolved" width="500">
|
|
4944
|
+
|
|
4945
|
+
Code to utilize this package and solve the puzzle:
|
|
4946
|
+
|
|
4947
|
+
(Note: the ids are arbitrary and simply represent cells that share a cage)
|
|
4948
|
+
|
|
4949
|
+
```python
|
|
4950
|
+
import numpy as np
|
|
4951
|
+
from puzzle_solver import sudoku_solver as solver
|
|
4952
|
+
board = np.full((9, 9), ' ')
|
|
4953
|
+
killer_board = np.array([
|
|
4954
|
+
['01', '01', '03', '03', '03', '12', '12', '13', '14'],
|
|
4955
|
+
['02', '01', '04', '16', '16', '17', '17', '13', '14'],
|
|
4956
|
+
['02', '02', '04', '18', '19', '19', '15', '15', '14'],
|
|
4957
|
+
['11', '11', '05', '18', '19', '19', '20', '15', '23'],
|
|
4958
|
+
['10', '10', '05', '30', '31', '32', '20', '22', '23'],
|
|
4959
|
+
['08', '07', '06', '30', '31', '32', '21', '22', '24'],
|
|
4960
|
+
['08', '07', '06', '29', '31', '33', '21', '24', '24'],
|
|
4961
|
+
['09', '34', '34', '29', '28', '33', '26', '26', '25'],
|
|
4962
|
+
['09', '34', '34', '28', '28', '27', '27', '25', '25'],
|
|
4963
|
+
])
|
|
4964
|
+
killer_clues = {
|
|
4965
|
+
'01': 16, '02': 11, '03': 24, '04': 10, '05': 11, '06': 7, '07': 10, '08': 10, '09': 16,
|
|
4966
|
+
'10': 11, '11': 10, '12': 7, '13': 11, '14': 16, '15': 16, '16': 8, '17': 12, '18': 8, '19': 15,
|
|
4967
|
+
'20': 7, '21': 10, '22': 5, '23': 13, '24': 16, '25': 9, '26': 14, '27': 15, '28': 13, '29': 11,
|
|
4968
|
+
'30': 9, '31': 15, '32': 13, '33': 11, '34': 15,
|
|
4969
|
+
}
|
|
4970
|
+
binst = solver.Board(board=board, block_size=(3, 3), killer=(killer_board, killer_clues))
|
|
4971
|
+
solutions = binst.solve_and_print()
|
|
4972
|
+
```
|
|
4973
|
+
|
|
4974
|
+
**Script Output**
|
|
4975
|
+
|
|
4976
|
+
```python
|
|
4977
|
+
Solution found
|
|
4978
|
+
[['5' '4' '8' '7' '9' '1' '6' '2' '3']
|
|
4979
|
+
['3' '7' '1' '6' '2' '8' '4' '9' '5']
|
|
4980
|
+
['2' '6' '9' '5' '4' '3' '1' '7' '8']
|
|
4981
|
+
['1' '9' '4' '3' '6' '2' '5' '8' '7']
|
|
4982
|
+
['8' '3' '7' '1' '5' '9' '2' '4' '6']
|
|
4983
|
+
['6' '2' '5' '8' '7' '4' '3' '1' '9']
|
|
4984
|
+
['4' '8' '2' '9' '3' '5' '7' '6' '1']
|
|
4985
|
+
['7' '1' '3' '2' '8' '6' '9' '5' '4']
|
|
4986
|
+
['9' '5' '6' '4' '1' '7' '8' '3' '2']]
|
|
4987
|
+
Solutions found: 1
|
|
4988
|
+
status: OPTIMAL
|
|
4989
|
+
Time taken: 0.01 seconds
|
|
4990
|
+
```
|
|
4991
|
+
|
|
4992
|
+
**Solved puzzle**
|
|
4993
|
+
|
|
4994
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/sudoku_killer_solved.png" alt="Sudoku Killer solved" width="500">
|
|
4995
|
+
|
|
4996
|
+
---
|
|
4997
|
+
|
|
4998
|
+
## Flood It (Puzzle Type #54)
|
|
4999
|
+
|
|
5000
|
+
* [**Play online**](https://www.chiark.greenend.org.uk/~sgtatham/puzzles/js/flood.html)
|
|
5001
|
+
|
|
5002
|
+
* [**Instructions**](https://www.chiark.greenend.org.uk/~sgtatham/puzzles/doc/flood.html#flood)
|
|
5003
|
+
|
|
5004
|
+
* [**Solver Code**][54]
|
|
5005
|
+
|
|
5006
|
+
<details>
|
|
5007
|
+
<summary><strong>Rules</strong></summary>
|
|
5008
|
+
|
|
5009
|
+
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.
|
|
5010
|
+
|
|
5011
|
+
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.
|
|
5012
|
+
|
|
5013
|
+
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.
|
|
5014
|
+
|
|
5015
|
+
</details>
|
|
5016
|
+
|
|
5017
|
+
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))
|
|
5018
|
+
|
|
5019
|
+
Finding an optimal solution for any graph is NP-hard.
|
|
5020
|
+
|
|
5021
|
+
**Unsolved puzzle**
|
|
5022
|
+
|
|
5023
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/flood_it_unsolved.png" alt="Flood It unsolved" width="500">
|
|
5024
|
+
|
|
5025
|
+
Code to utilize this package and solve the puzzle:
|
|
5026
|
+
|
|
5027
|
+
(Note: the ids are arbitrary and simply represent cells that share a cage)
|
|
5028
|
+
|
|
5029
|
+
```python
|
|
5030
|
+
import numpy as np
|
|
5031
|
+
from puzzle_solver import flood_it_solver as solver
|
|
5032
|
+
board = np.array([
|
|
5033
|
+
['B', 'Y', 'G', 'Y', 'R', 'B', 'Y', 'Y', 'G', 'B', 'R', 'P'],
|
|
5034
|
+
['P', 'G', 'G', 'Y', 'B', 'O', 'Y', 'O', 'B', 'Y', 'R', 'O'],
|
|
5035
|
+
['B', 'R', 'P', 'Y', 'O', 'R', 'G', 'G', 'G', 'R', 'R', 'Y'],
|
|
5036
|
+
['O', 'G', 'P', 'G', 'Y', 'Y', 'P', 'P', 'O', 'Y', 'B', 'B'],
|
|
5037
|
+
['G', 'Y', 'G', 'O', 'R', 'G', 'R', 'P', 'G', 'O', 'B', 'R'],
|
|
5038
|
+
['R', 'G', 'B', 'G', 'O', 'B', 'O', 'G', 'B', 'O', 'O', 'B'],
|
|
5039
|
+
['G', 'B', 'P', 'R', 'Y', 'P', 'R', 'B', 'Y', 'B', 'Y', 'P'],
|
|
5040
|
+
['G', 'B', 'G', 'P', 'O', 'Y', 'R', 'Y', 'P', 'P', 'O', 'G'],
|
|
5041
|
+
['R', 'P', 'B', 'O', 'B', 'G', 'Y', 'O', 'Y', 'R', 'P', 'O'],
|
|
5042
|
+
['G', 'P', 'P', 'P', 'P', 'Y', 'G', 'P', 'O', 'G', 'O', 'R'],
|
|
5043
|
+
['Y', 'Y', 'B', 'B', 'R', 'B', 'O', 'R', 'O', 'O', 'R', 'O'],
|
|
5044
|
+
['B', 'G', 'B', 'G', 'R', 'B', 'P', 'Y', 'P', 'B', 'R', 'G']
|
|
5045
|
+
])
|
|
5046
|
+
solution = solver.solve_minimum_steps(board=board)
|
|
5047
|
+
```
|
|
5048
|
+
|
|
5049
|
+
**Script Output**
|
|
5050
|
+
|
|
5051
|
+
```python
|
|
5052
|
+
Trying with exactly 16 moves... Not possible!
|
|
5053
|
+
Trying with exactly 32 moves... Possible!
|
|
5054
|
+
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']
|
|
5055
|
+
Trying with exactly 24 moves... Possible!
|
|
5056
|
+
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']
|
|
5057
|
+
Trying with exactly 20 moves... Possible!
|
|
5058
|
+
Solution: ['Y', 'G', 'B', 'Y', 'B', 'R', 'B', 'G', 'Y', 'G', 'B', 'G', 'Y', 'B', 'Y', 'R', 'B', 'G', 'R', 'Y']
|
|
5059
|
+
Trying with exactly 18 moves... Possible!
|
|
5060
|
+
Solution: ['Y', 'G', 'B', 'Y', 'R', 'B', 'R', 'Y', 'B', 'G', 'R', 'Y', 'R', 'B', 'G', 'R', 'Y', 'B']
|
|
5061
|
+
Trying with exactly 17 moves... Not possible!
|
|
5062
|
+
Best Horizon is: T=18
|
|
5063
|
+
Best solution is: ['Y', 'G', 'B', 'Y', 'R', 'B', 'R', 'Y', 'B', 'G', 'R', 'Y', 'R', 'B', 'G', 'R', 'Y', 'B']
|
|
5064
|
+
Time taken: 3.10 seconds
|
|
5065
|
+
```
|
|
5066
|
+
|
|
5067
|
+
**Solved puzzle**
|
|
5068
|
+
|
|
5069
|
+
This picture won't mean much as the game is about the sequence and number of moves not the final frame as shown here.
|
|
5070
|
+
|
|
5071
|
+
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.
|
|
5072
|
+
|
|
5073
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/flood_it_solved.png" alt="Flood It solved" width="500">
|
|
5074
|
+
|
|
5075
|
+
---
|
|
5076
|
+
|
|
4825
5077
|
---
|
|
4826
5078
|
|
|
4827
5079
|
## Why SAT / CP-SAT?
|
|
@@ -4924,3 +5176,6 @@ Issues and PRs welcome!
|
|
|
4924
5176
|
[49]: https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/binairo_plus "puzzle_solver/src/puzzle_solver/puzzles/binairo_plus at master · Ar-Kareem/puzzle_solver · GitHub"
|
|
4925
5177
|
[50]: https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/shakashaka "puzzle_solver/src/puzzle_solver/puzzles/shakashaka at master · Ar-Kareem/puzzle_solver · GitHub"
|
|
4926
5178
|
[51]: https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/kakuro "puzzle_solver/src/puzzle_solver/puzzles/kakuro at master · Ar-Kareem/puzzle_solver · GitHub"
|
|
5179
|
+
[52]: https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/sudoku "puzzle_solver/src/puzzle_solver/puzzles/sudoku at master · Ar-Kareem/puzzle_solver · GitHub"
|
|
5180
|
+
[53]: https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/sudoku "puzzle_solver/src/puzzle_solver/puzzles/sudoku at master · Ar-Kareem/puzzle_solver · GitHub"
|
|
5181
|
+
[54]: https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/flood_it "puzzle_solver/src/puzzle_solver/puzzles/flood_it at master · Ar-Kareem/puzzle_solver · GitHub"
|