multi-puzzle-solver 0.9.12__tar.gz → 0.9.14__tar.gz
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.12/src/multi_puzzle_solver.egg-info → multi_puzzle_solver-0.9.14}/PKG-INFO +128 -17
- multi_puzzle_solver-0.9.12/PKG-INFO → multi_puzzle_solver-0.9.14/README.md +2953 -2868
- multi_puzzle_solver-0.9.12/README.md → multi_puzzle_solver-0.9.14/src/multi_puzzle_solver.egg-info/PKG-INFO +2979 -2842
- {multi_puzzle_solver-0.9.12 → multi_puzzle_solver-0.9.14}/src/multi_puzzle_solver.egg-info/SOURCES.txt +4 -2
- {multi_puzzle_solver-0.9.12 → multi_puzzle_solver-0.9.14}/src/puzzle_solver/__init__.py +3 -2
- multi_puzzle_solver-0.9.14/src/puzzle_solver/core/utils.py +228 -0
- multi_puzzle_solver-0.9.14/src/puzzle_solver/core/utils_ortools.py +235 -0
- {multi_puzzle_solver-0.9.12 → multi_puzzle_solver-0.9.14}/src/puzzle_solver/puzzles/battleships/battleships.py +1 -0
- multi_puzzle_solver-0.9.14/src/puzzle_solver/puzzles/black_box/black_box.py +313 -0
- multi_puzzle_solver-0.9.14/src/puzzle_solver/puzzles/filling/filling.py +117 -0
- {multi_puzzle_solver-0.9.12 → multi_puzzle_solver-0.9.14}/src/puzzle_solver/puzzles/inertia/tsp.py +4 -1
- multi_puzzle_solver-0.9.12/src/puzzle_solver/puzzles/norinori/norinori.py → multi_puzzle_solver-0.9.14/src/puzzle_solver/puzzles/lits/lits.py +162 -255
- {multi_puzzle_solver-0.9.12 → multi_puzzle_solver-0.9.14}/src/puzzle_solver/puzzles/pearl/pearl.py +12 -44
- {multi_puzzle_solver-0.9.12 → multi_puzzle_solver-0.9.14}/src/puzzle_solver/puzzles/range/range.py +2 -51
- {multi_puzzle_solver-0.9.12 → multi_puzzle_solver-0.9.14}/src/puzzle_solver/puzzles/singles/singles.py +9 -50
- {multi_puzzle_solver-0.9.12 → multi_puzzle_solver-0.9.14}/src/puzzle_solver/puzzles/stitches/parse_map/parse_map.py +212 -212
- {multi_puzzle_solver-0.9.12 → multi_puzzle_solver-0.9.14}/src/puzzle_solver/puzzles/tracks/tracks.py +12 -41
- multi_puzzle_solver-0.9.14/tests/test_black_box.py +40 -0
- {multi_puzzle_solver-0.9.12 → multi_puzzle_solver-0.9.14}/tests/test_chess_melee.py +37 -37
- {multi_puzzle_solver-0.9.12 → multi_puzzle_solver-0.9.14}/tests/test_filling.py +129 -106
- {multi_puzzle_solver-0.9.12 → multi_puzzle_solver-0.9.14}/tests/test_inertia.py +16 -4
- multi_puzzle_solver-0.9.12/tests/test_norinori.py → multi_puzzle_solver-0.9.14/tests/test_lits.py +104 -107
- multi_puzzle_solver-0.9.12/src/puzzle_solver/core/utils.py +0 -127
- multi_puzzle_solver-0.9.12/src/puzzle_solver/core/utils_ortools.py +0 -172
- multi_puzzle_solver-0.9.12/src/puzzle_solver/puzzles/filling/filling.py +0 -192
- {multi_puzzle_solver-0.9.12 → multi_puzzle_solver-0.9.14}/pyproject.toml +0 -0
- {multi_puzzle_solver-0.9.12 → multi_puzzle_solver-0.9.14}/setup.cfg +0 -0
- {multi_puzzle_solver-0.9.12 → multi_puzzle_solver-0.9.14}/src/multi_puzzle_solver.egg-info/dependency_links.txt +0 -0
- {multi_puzzle_solver-0.9.12 → multi_puzzle_solver-0.9.14}/src/multi_puzzle_solver.egg-info/requires.txt +0 -0
- {multi_puzzle_solver-0.9.12 → multi_puzzle_solver-0.9.14}/src/multi_puzzle_solver.egg-info/top_level.txt +0 -0
- {multi_puzzle_solver-0.9.12 → multi_puzzle_solver-0.9.14}/src/puzzle_solver/puzzles/aquarium/aquarium.py +0 -0
- {multi_puzzle_solver-0.9.12 → multi_puzzle_solver-0.9.14}/src/puzzle_solver/puzzles/bridges/bridges.py +0 -0
- {multi_puzzle_solver-0.9.12 → multi_puzzle_solver-0.9.14}/src/puzzle_solver/puzzles/chess_range/chess_melee.py +0 -0
- {multi_puzzle_solver-0.9.12 → multi_puzzle_solver-0.9.14}/src/puzzle_solver/puzzles/chess_range/chess_range.py +0 -0
- {multi_puzzle_solver-0.9.12 → multi_puzzle_solver-0.9.14}/src/puzzle_solver/puzzles/chess_range/chess_solo.py +0 -0
- {multi_puzzle_solver-0.9.12 → multi_puzzle_solver-0.9.14}/src/puzzle_solver/puzzles/dominosa/dominosa.py +0 -0
- {multi_puzzle_solver-0.9.12 → multi_puzzle_solver-0.9.14}/src/puzzle_solver/puzzles/guess/guess.py +0 -0
- {multi_puzzle_solver-0.9.12 → multi_puzzle_solver-0.9.14}/src/puzzle_solver/puzzles/inertia/inertia.py +0 -0
- {multi_puzzle_solver-0.9.12 → multi_puzzle_solver-0.9.14}/src/puzzle_solver/puzzles/inertia/parse_map/parse_map.py +0 -0
- {multi_puzzle_solver-0.9.12 → multi_puzzle_solver-0.9.14}/src/puzzle_solver/puzzles/kakurasu/kakurasu.py +0 -0
- {multi_puzzle_solver-0.9.12 → multi_puzzle_solver-0.9.14}/src/puzzle_solver/puzzles/keen/keen.py +0 -0
- {multi_puzzle_solver-0.9.12 → multi_puzzle_solver-0.9.14}/src/puzzle_solver/puzzles/light_up/light_up.py +0 -0
- {multi_puzzle_solver-0.9.12 → multi_puzzle_solver-0.9.14}/src/puzzle_solver/puzzles/magnets/magnets.py +0 -0
- {multi_puzzle_solver-0.9.12 → multi_puzzle_solver-0.9.14}/src/puzzle_solver/puzzles/map/map.py +0 -0
- {multi_puzzle_solver-0.9.12 → multi_puzzle_solver-0.9.14}/src/puzzle_solver/puzzles/minesweeper/minesweeper.py +0 -0
- {multi_puzzle_solver-0.9.12 → multi_puzzle_solver-0.9.14}/src/puzzle_solver/puzzles/mosaic/mosaic.py +0 -0
- {multi_puzzle_solver-0.9.12 → multi_puzzle_solver-0.9.14}/src/puzzle_solver/puzzles/nonograms/nonograms.py +0 -0
- {multi_puzzle_solver-0.9.12 → multi_puzzle_solver-0.9.14}/src/puzzle_solver/puzzles/signpost/signpost.py +0 -0
- {multi_puzzle_solver-0.9.12 → multi_puzzle_solver-0.9.14}/src/puzzle_solver/puzzles/star_battle/star_battle.py +0 -0
- {multi_puzzle_solver-0.9.12 → multi_puzzle_solver-0.9.14}/src/puzzle_solver/puzzles/star_battle/star_battle_shapeless.py +0 -0
- {multi_puzzle_solver-0.9.12 → multi_puzzle_solver-0.9.14}/src/puzzle_solver/puzzles/stitches/stitches.py +0 -0
- {multi_puzzle_solver-0.9.12 → multi_puzzle_solver-0.9.14}/src/puzzle_solver/puzzles/sudoku/sudoku.py +0 -0
- {multi_puzzle_solver-0.9.12 → multi_puzzle_solver-0.9.14}/src/puzzle_solver/puzzles/tents/tents.py +0 -0
- {multi_puzzle_solver-0.9.12 → multi_puzzle_solver-0.9.14}/src/puzzle_solver/puzzles/thermometers/thermometers.py +0 -0
- {multi_puzzle_solver-0.9.12 → multi_puzzle_solver-0.9.14}/src/puzzle_solver/puzzles/towers/towers.py +0 -0
- {multi_puzzle_solver-0.9.12 → multi_puzzle_solver-0.9.14}/src/puzzle_solver/puzzles/undead/undead.py +0 -0
- {multi_puzzle_solver-0.9.12 → multi_puzzle_solver-0.9.14}/src/puzzle_solver/puzzles/unruly/unruly.py +0 -0
- {multi_puzzle_solver-0.9.12 → multi_puzzle_solver-0.9.14}/src/puzzle_solver/utils/visualizer.py +0 -0
- {multi_puzzle_solver-0.9.12 → multi_puzzle_solver-0.9.14}/tests/test_aquarium.py +0 -0
- {multi_puzzle_solver-0.9.12 → multi_puzzle_solver-0.9.14}/tests/test_battleships.py +0 -0
- {multi_puzzle_solver-0.9.12 → multi_puzzle_solver-0.9.14}/tests/test_bridges.py +0 -0
- {multi_puzzle_solver-0.9.12 → multi_puzzle_solver-0.9.14}/tests/test_chess_range.py +0 -0
- {multi_puzzle_solver-0.9.12 → multi_puzzle_solver-0.9.14}/tests/test_chess_solo.py +0 -0
- {multi_puzzle_solver-0.9.12 → multi_puzzle_solver-0.9.14}/tests/test_dominosa.py +0 -0
- {multi_puzzle_solver-0.9.12 → multi_puzzle_solver-0.9.14}/tests/test_guess.py +0 -0
- {multi_puzzle_solver-0.9.12 → multi_puzzle_solver-0.9.14}/tests/test_kakurasu.py +0 -0
- {multi_puzzle_solver-0.9.12 → multi_puzzle_solver-0.9.14}/tests/test_keen.py +0 -0
- {multi_puzzle_solver-0.9.12 → multi_puzzle_solver-0.9.14}/tests/test_light_up.py +0 -0
- {multi_puzzle_solver-0.9.12 → multi_puzzle_solver-0.9.14}/tests/test_magnets.py +0 -0
- {multi_puzzle_solver-0.9.12 → multi_puzzle_solver-0.9.14}/tests/test_map.py +0 -0
- {multi_puzzle_solver-0.9.12 → multi_puzzle_solver-0.9.14}/tests/test_minesweeper.py +0 -0
- {multi_puzzle_solver-0.9.12 → multi_puzzle_solver-0.9.14}/tests/test_mosaic.py +0 -0
- {multi_puzzle_solver-0.9.12 → multi_puzzle_solver-0.9.14}/tests/test_nonograms.py +0 -0
- {multi_puzzle_solver-0.9.12 → multi_puzzle_solver-0.9.14}/tests/test_pearl.py +0 -0
- {multi_puzzle_solver-0.9.12 → multi_puzzle_solver-0.9.14}/tests/test_range.py +0 -0
- {multi_puzzle_solver-0.9.12 → multi_puzzle_solver-0.9.14}/tests/test_signpost.py +0 -0
- {multi_puzzle_solver-0.9.12 → multi_puzzle_solver-0.9.14}/tests/test_singles.py +0 -0
- {multi_puzzle_solver-0.9.12 → multi_puzzle_solver-0.9.14}/tests/test_star_battle.py +0 -0
- {multi_puzzle_solver-0.9.12 → multi_puzzle_solver-0.9.14}/tests/test_stitches.py +0 -0
- {multi_puzzle_solver-0.9.12 → multi_puzzle_solver-0.9.14}/tests/test_sudoku.py +0 -0
- {multi_puzzle_solver-0.9.12 → multi_puzzle_solver-0.9.14}/tests/test_tents.py +0 -0
- {multi_puzzle_solver-0.9.12 → multi_puzzle_solver-0.9.14}/tests/test_thermometers.py +0 -0
- {multi_puzzle_solver-0.9.12 → multi_puzzle_solver-0.9.14}/tests/test_towers.py +0 -0
- {multi_puzzle_solver-0.9.12 → multi_puzzle_solver-0.9.14}/tests/test_tracks.py +0 -0
- {multi_puzzle_solver-0.9.12 → multi_puzzle_solver-0.9.14}/tests/test_undead.py +0 -0
- {multi_puzzle_solver-0.9.12 → multi_puzzle_solver-0.9.14}/tests/test_unruly.py +0 -0
{multi_puzzle_solver-0.9.12/src/multi_puzzle_solver.egg-info → multi_puzzle_solver-0.9.14}/PKG-INFO
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: multi-puzzle-solver
|
|
3
|
-
Version: 0.9.
|
|
3
|
+
Version: 0.9.14
|
|
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
|
|
@@ -260,8 +260,13 @@ These are all the puzzles that are implemented in this repo. <br> Click on any o
|
|
|
260
260
|
</a>
|
|
261
261
|
</td>
|
|
262
262
|
<td align="center">
|
|
263
|
-
<a href="#
|
|
264
|
-
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/
|
|
263
|
+
<a href="#lits-puzzle-type-33"><b>Lits</b><br><br>
|
|
264
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/lits_solved.png" alt="Lits" width="140">
|
|
265
|
+
</a>
|
|
266
|
+
</td>
|
|
267
|
+
<td align="center">
|
|
268
|
+
<a href="#black-box-puzzle-type-34"><b>Black Box</b><br><br>
|
|
269
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/black_box_solved.png" alt="Black Box" width="140">
|
|
265
270
|
</a>
|
|
266
271
|
</td>
|
|
267
272
|
</tr>
|
|
@@ -311,7 +316,8 @@ These are all the puzzles that are implemented in this repo. <br> Click on any o
|
|
|
311
316
|
- [Kakurasu (Puzzle Type #30)](#kakurasu-puzzle-type-30)
|
|
312
317
|
- [Star Battle (Puzzle Type #31)](#star-battle-puzzle-type-31)
|
|
313
318
|
- [Star Battle Shapeless (Puzzle Type #32)](#star-battle-shapeless-puzzle-type-32)
|
|
314
|
-
- [
|
|
319
|
+
- [Lits (Puzzle Type #33)](#lits-puzzle-type-33)
|
|
320
|
+
- [Black Box (Puzzle Type #34)](#black-box-puzzle-type-34)
|
|
315
321
|
- [Why SAT / CP-SAT?](#why-sat--cp-sat)
|
|
316
322
|
- [Testing](#testing)
|
|
317
323
|
- [Contributing](#contributing)
|
|
@@ -804,7 +810,7 @@ You have a grid of squares, some of which contain digits, and the rest of which
|
|
|
804
810
|
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).
|
|
805
811
|
</details>
|
|
806
812
|
|
|
807
|
-
|
|
813
|
+
Note: It may take a few seconds for the model to be built.
|
|
808
814
|
|
|
809
815
|
**Unsolved puzzle**
|
|
810
816
|
|
|
@@ -837,7 +843,7 @@ Solution found
|
|
|
837
843
|
[1 6 6 1 4 4 4]]
|
|
838
844
|
Solutions found: 1
|
|
839
845
|
status: OPTIMAL
|
|
840
|
-
Time taken:
|
|
846
|
+
Time taken: 0.10 seconds
|
|
841
847
|
```
|
|
842
848
|
|
|
843
849
|
**Solved puzzle**
|
|
@@ -1212,8 +1218,6 @@ You have a grid of squares; some squares contain numbers. Your job is to colour
|
|
|
1212
1218
|
For instance, a square containing the number one must have four black squares as its neighbours 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.
|
|
1213
1219
|
</details>
|
|
1214
1220
|
|
|
1215
|
-
(Note: The solver for this puzzle is slightly slower and could take several seconds to solve a 16x11 puzzle)
|
|
1216
|
-
|
|
1217
1221
|
**Unsolved puzzle**
|
|
1218
1222
|
|
|
1219
1223
|
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/range_unsolved.png" alt="Range unsolved" width="500">
|
|
@@ -1254,7 +1258,7 @@ B . . . B . B . . . . . B . . .
|
|
|
1254
1258
|
B . . . . . . B . . . . B . . .
|
|
1255
1259
|
Solutions found: 1
|
|
1256
1260
|
status: OPTIMAL
|
|
1257
|
-
Time taken:
|
|
1261
|
+
Time taken: 0.04 seconds
|
|
1258
1262
|
```
|
|
1259
1263
|
|
|
1260
1264
|
**Solved puzzle**
|
|
@@ -1410,8 +1414,6 @@ Complete the track from A to B so that the rows and columns contain the same num
|
|
|
1410
1414
|
|
|
1411
1415
|
</details>
|
|
1412
1416
|
|
|
1413
|
-
(Note: The solver for this puzzle is slightly slower and could take several seconds to solve a large 15x15 puzzle)
|
|
1414
|
-
|
|
1415
1417
|
**Unsolved puzzle**
|
|
1416
1418
|
|
|
1417
1419
|
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/tracks_unsolved.png" alt="Tracks unsolved" width="500">
|
|
@@ -1461,7 +1463,7 @@ solutions = binst.solve_and_print()
|
|
|
1461
1463
|
[' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' '┏━' '━┛']]
|
|
1462
1464
|
Solutions found: 1
|
|
1463
1465
|
status: OPTIMAL
|
|
1464
|
-
Time taken:
|
|
1466
|
+
Time taken: 1.04 seconds
|
|
1465
1467
|
```
|
|
1466
1468
|
|
|
1467
1469
|
**Solved puzzle**
|
|
@@ -2693,9 +2695,9 @@ Time taken: 0.02 seconds
|
|
|
2693
2695
|
|
|
2694
2696
|
---
|
|
2695
2697
|
|
|
2696
|
-
##
|
|
2698
|
+
## Lits (Puzzle Type #33)
|
|
2697
2699
|
|
|
2698
|
-
* [**Play online**](https://www.puzzle-
|
|
2700
|
+
* [**Play online**](https://www.puzzle-lits.com/)
|
|
2699
2701
|
|
|
2700
2702
|
* [**Solver Code**][33]
|
|
2701
2703
|
|
|
@@ -2715,7 +2717,7 @@ Note: The solver is capable of solving variations where the puzzle pieces the ma
|
|
|
2715
2717
|
|
|
2716
2718
|
**Unsolved puzzle**
|
|
2717
2719
|
|
|
2718
|
-
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/
|
|
2720
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/lits_unsolved.png" alt="Lits unsolved" width="500">
|
|
2719
2721
|
|
|
2720
2722
|
Code to utilize this package and solve the puzzle:
|
|
2721
2723
|
|
|
@@ -2778,7 +2780,115 @@ Time taken: 0.38 seconds
|
|
|
2778
2780
|
|
|
2779
2781
|
**Solved puzzle**
|
|
2780
2782
|
|
|
2781
|
-
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/
|
|
2783
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/lits_solved.png" alt="Lits solved" width="500">
|
|
2784
|
+
|
|
2785
|
+
---
|
|
2786
|
+
|
|
2787
|
+
## Black Box (Puzzle Type #34)
|
|
2788
|
+
|
|
2789
|
+
* [**Play online**](https://www.chiark.greenend.org.uk/~sgtatham/puzzles/js/blackbox.html)
|
|
2790
|
+
|
|
2791
|
+
* [**Instructions**](https://www.chiark.greenend.org.uk/~sgtatham/puzzles/doc/blackbox.html#blackbox)
|
|
2792
|
+
|
|
2793
|
+
* [**Solver Code**][34]
|
|
2794
|
+
|
|
2795
|
+
<details>
|
|
2796
|
+
<summary><strong>Rules</strong></summary>
|
|
2797
|
+
|
|
2798
|
+
A number of balls are hidden in a rectangular arena. You have to deduce the positions of the balls by firing lasers positioned at the edges of the arena and observing how their beams are deflected.
|
|
2799
|
+
|
|
2800
|
+
Beams will travel straight from their origin until they hit the opposite side of the arena (at which point they emerge), unless affected by balls in one of the following ways:
|
|
2801
|
+
|
|
2802
|
+
A beam that hits a ball head-on is absorbed and will never re-emerge. This includes beams that meet a ball on the first rank of the arena.
|
|
2803
|
+
A beam with a ball in its front-left square and no ball ahead of it gets deflected 90 degrees to the right.
|
|
2804
|
+
A beam with a ball in its front-right square and no ball ahead of it gets similarly deflected to the left.
|
|
2805
|
+
A beam that would re-emerge from its entry location is considered to be ‘reflected’.
|
|
2806
|
+
A beam which would get deflected before entering the arena by a ball to the front-left or front-right of its entry point is also considered to be ‘reflected’.
|
|
2807
|
+
|
|
2808
|
+
Beams that are reflected appear as a ‘R’; beams that hit balls head-on appear as ‘H’. Otherwise, a number appears at the firing point and the location where the beam emerges (this number is unique to that shot).
|
|
2809
|
+
|
|
2810
|
+
You can place guesses as to the location of the balls, based on the entry and exit patterns of the beams; once you have placed enough balls a button appears enabling you to have your guesses checked.
|
|
2811
|
+
|
|
2812
|
+
Here is a diagram showing how the positions of balls can create each of the beam behaviours shown above:
|
|
2813
|
+
|
|
2814
|
+
1 R H R - - - -
|
|
2815
|
+
| . . O . O . . . |
|
|
2816
|
+
2 . . . . . . . . 3
|
|
2817
|
+
| . . . . . . . . |
|
|
2818
|
+
| . . . . . . . . |
|
|
2819
|
+
3 . . . . . . . . |
|
|
2820
|
+
| . . . . . . O . |
|
|
2821
|
+
H . . . . . . . . |
|
|
2822
|
+
| . . . . . O . . |
|
|
2823
|
+
1 2 - R R - - -
|
|
2824
|
+
|
|
2825
|
+
As shown, it is possible for a beam to receive multiple reflections before re-emerging (see turn 3). Similarly, a beam may be reflected (possibly more than once) before receiving a hit (the ‘H’ on the left side of the example).
|
|
2826
|
+
|
|
2827
|
+
Note that any layout with more than 4 balls may have a non-unique solution. The following diagram illustrates this; if you know the board contains 5 balls, it is impossible to determine where the fifth ball is (possible positions marked with an x):
|
|
2828
|
+
|
|
2829
|
+
- - - - - - - -
|
|
2830
|
+
| . . . . . . . . |
|
|
2831
|
+
| . . . . . . . . |
|
|
2832
|
+
| . . O . . O . . |
|
|
2833
|
+
| . . . x x . . . |
|
|
2834
|
+
| . . . x x . . . |
|
|
2835
|
+
| . . O . . O . . |
|
|
2836
|
+
| . . . . . . . . |
|
|
2837
|
+
| . . . . . . . . |
|
|
2838
|
+
- - - - - - - -
|
|
2839
|
+
|
|
2840
|
+
For this reason, when you have your guesses checked, the game will check that your solution produces the same results as the computer's, rather than that your solution is identical to the computer's. So in the above example, you could put the fifth ball at any of the locations marked with an x, and you would still win.
|
|
2841
|
+
</details>
|
|
2842
|
+
|
|
2843
|
+
Note: This puzzle is one of the very rare puzzles where CP-SAT is not a good fit because for every placement of the balls the state of the beams is dynamically changes and thus required a lot of variables to construct and constraint. This is why the resulting model is large and slow.
|
|
2844
|
+
|
|
2845
|
+
**Unsolved puzzle**
|
|
2846
|
+
|
|
2847
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/black_box_unsolved.png" alt="Black Box unsolved" width="500">
|
|
2848
|
+
|
|
2849
|
+
Code to utilize this package and solve the puzzle:
|
|
2850
|
+
```python
|
|
2851
|
+
from puzzle_solver import black_box_solver as solver
|
|
2852
|
+
top = ['1', 'H', 'R', 'R', 'H', 'R', '2', '3']
|
|
2853
|
+
left = ['H', '1', 'H', '7', '5', '6', 'H', 'H']
|
|
2854
|
+
right = ['2', 'H', '4', 'H', '5', '6', 'H', 'H']
|
|
2855
|
+
bottom = ['7', 'R', 'H', 'R', 'H', 'R', '4', '3']
|
|
2856
|
+
|
|
2857
|
+
# create board and solve; ball count if between 3 and 6
|
|
2858
|
+
binst = solver.Board(top=top, left=left, bottom=bottom, right=right, ball_count=(3, 6))
|
|
2859
|
+
solutions = binst.solve_and_print()
|
|
2860
|
+
```
|
|
2861
|
+
**Script Output**
|
|
2862
|
+
|
|
2863
|
+
As the instructions say, the solution to this puzzle is not garunteed to be unique.
|
|
2864
|
+
|
|
2865
|
+
```python
|
|
2866
|
+
Solution found
|
|
2867
|
+
[[' ' ' ' ' ' ' ' 'O' ' ' ' ' ' ']
|
|
2868
|
+
[' ' ' ' ' ' ' ' ' ' 'O' ' ' ' ']
|
|
2869
|
+
[' ' 'O' ' ' ' ' ' ' ' ' ' ' ' ']
|
|
2870
|
+
[' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ']
|
|
2871
|
+
[' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ']
|
|
2872
|
+
[' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ']
|
|
2873
|
+
[' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ']
|
|
2874
|
+
[' ' ' ' 'O' ' ' 'O' ' ' ' ' ' ']]
|
|
2875
|
+
Solution found
|
|
2876
|
+
[[' ' ' ' ' ' ' ' 'O' ' ' ' ' ' ']
|
|
2877
|
+
[' ' ' ' ' ' ' ' ' ' 'O' ' ' ' ']
|
|
2878
|
+
[' ' 'O' ' ' 'O' ' ' ' ' ' ' ' ']
|
|
2879
|
+
[' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ']
|
|
2880
|
+
[' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ']
|
|
2881
|
+
[' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ']
|
|
2882
|
+
[' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ']
|
|
2883
|
+
[' ' ' ' 'O' ' ' 'O' ' ' ' ' ' ']]
|
|
2884
|
+
Solutions found: 2
|
|
2885
|
+
status: OPTIMAL
|
|
2886
|
+
Time taken: 30.33 seconds
|
|
2887
|
+
```
|
|
2888
|
+
|
|
2889
|
+
**Solved puzzle**
|
|
2890
|
+
|
|
2891
|
+
<img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/black_box_solved.png" alt="Black Box solved" width="500">
|
|
2782
2892
|
|
|
2783
2893
|
---
|
|
2784
2894
|
|
|
@@ -2865,4 +2975,5 @@ Issues and PRs welcome!
|
|
|
2865
2975
|
[30]: https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/kakurasu "puzzle_solver/src/puzzle_solver/puzzles/kakurasu at master · Ar-Kareem/puzzle_solver · GitHub"
|
|
2866
2976
|
[31]: https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/star_battle "puzzle_solver/src/puzzle_solver/puzzles/star_battle at master · Ar-Kareem/puzzle_solver · GitHub"
|
|
2867
2977
|
[32]: https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/star_battle_shapeless "puzzle_solver/src/puzzle_solver/puzzles/star_battle_shapeless at master · Ar-Kareem/puzzle_solver · GitHub"
|
|
2868
|
-
[33]: https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/
|
|
2978
|
+
[33]: https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/lits "puzzle_solver/src/puzzle_solver/puzzles/lits at master · Ar-Kareem/puzzle_solver · GitHub"
|
|
2979
|
+
[34]: https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/black_box "puzzle_solver/src/puzzle_solver/puzzles/black_box at master · Ar-Kareem/puzzle_solver · GitHub"
|