multi-puzzle-solver 0.9.15__tar.gz → 0.9.18__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.

Files changed (91) hide show
  1. {multi_puzzle_solver-0.9.15 → multi_puzzle_solver-0.9.18}/PKG-INFO +292 -11
  2. {multi_puzzle_solver-0.9.15 → multi_puzzle_solver-0.9.18}/README.md +291 -10
  3. {multi_puzzle_solver-0.9.15 → multi_puzzle_solver-0.9.18}/src/multi_puzzle_solver.egg-info/PKG-INFO +292 -11
  4. {multi_puzzle_solver-0.9.15 → multi_puzzle_solver-0.9.18}/src/multi_puzzle_solver.egg-info/SOURCES.txt +5 -0
  5. {multi_puzzle_solver-0.9.15 → multi_puzzle_solver-0.9.18}/src/puzzle_solver/__init__.py +3 -1
  6. {multi_puzzle_solver-0.9.15 → multi_puzzle_solver-0.9.18}/src/puzzle_solver/core/utils_ortools.py +21 -17
  7. {multi_puzzle_solver-0.9.15 → multi_puzzle_solver-0.9.18}/src/puzzle_solver/puzzles/galaxies/galaxies.py +2 -2
  8. {multi_puzzle_solver-0.9.15 → multi_puzzle_solver-0.9.18}/src/puzzle_solver/puzzles/galaxies/parse_map/parse_map.py +1 -1
  9. multi_puzzle_solver-0.9.18/src/puzzle_solver/puzzles/slant/parse_map/parse_map.py +133 -0
  10. multi_puzzle_solver-0.9.18/src/puzzle_solver/puzzles/slant/slant.py +117 -0
  11. {multi_puzzle_solver-0.9.15 → multi_puzzle_solver-0.9.18}/src/puzzle_solver/puzzles/stitches/parse_map/parse_map.py +1 -1
  12. multi_puzzle_solver-0.9.18/src/puzzle_solver/puzzles/unequal/unequal.py +128 -0
  13. {multi_puzzle_solver-0.9.15 → multi_puzzle_solver-0.9.18}/tests/test_galaxies.py +2 -7
  14. multi_puzzle_solver-0.9.18/tests/test_slant.py +141 -0
  15. multi_puzzle_solver-0.9.18/tests/test_unequal.py +137 -0
  16. {multi_puzzle_solver-0.9.15 → multi_puzzle_solver-0.9.18}/pyproject.toml +0 -0
  17. {multi_puzzle_solver-0.9.15 → multi_puzzle_solver-0.9.18}/setup.cfg +0 -0
  18. {multi_puzzle_solver-0.9.15 → multi_puzzle_solver-0.9.18}/src/multi_puzzle_solver.egg-info/dependency_links.txt +0 -0
  19. {multi_puzzle_solver-0.9.15 → multi_puzzle_solver-0.9.18}/src/multi_puzzle_solver.egg-info/requires.txt +0 -0
  20. {multi_puzzle_solver-0.9.15 → multi_puzzle_solver-0.9.18}/src/multi_puzzle_solver.egg-info/top_level.txt +0 -0
  21. {multi_puzzle_solver-0.9.15 → multi_puzzle_solver-0.9.18}/src/puzzle_solver/core/utils.py +0 -0
  22. {multi_puzzle_solver-0.9.15 → multi_puzzle_solver-0.9.18}/src/puzzle_solver/puzzles/aquarium/aquarium.py +0 -0
  23. {multi_puzzle_solver-0.9.15 → multi_puzzle_solver-0.9.18}/src/puzzle_solver/puzzles/battleships/battleships.py +0 -0
  24. {multi_puzzle_solver-0.9.15 → multi_puzzle_solver-0.9.18}/src/puzzle_solver/puzzles/black_box/black_box.py +0 -0
  25. {multi_puzzle_solver-0.9.15 → multi_puzzle_solver-0.9.18}/src/puzzle_solver/puzzles/bridges/bridges.py +0 -0
  26. {multi_puzzle_solver-0.9.15 → multi_puzzle_solver-0.9.18}/src/puzzle_solver/puzzles/chess_range/chess_melee.py +0 -0
  27. {multi_puzzle_solver-0.9.15 → multi_puzzle_solver-0.9.18}/src/puzzle_solver/puzzles/chess_range/chess_range.py +0 -0
  28. {multi_puzzle_solver-0.9.15 → multi_puzzle_solver-0.9.18}/src/puzzle_solver/puzzles/chess_range/chess_solo.py +0 -0
  29. {multi_puzzle_solver-0.9.15 → multi_puzzle_solver-0.9.18}/src/puzzle_solver/puzzles/dominosa/dominosa.py +0 -0
  30. {multi_puzzle_solver-0.9.15 → multi_puzzle_solver-0.9.18}/src/puzzle_solver/puzzles/filling/filling.py +0 -0
  31. {multi_puzzle_solver-0.9.15 → multi_puzzle_solver-0.9.18}/src/puzzle_solver/puzzles/guess/guess.py +0 -0
  32. {multi_puzzle_solver-0.9.15 → multi_puzzle_solver-0.9.18}/src/puzzle_solver/puzzles/inertia/inertia.py +0 -0
  33. {multi_puzzle_solver-0.9.15 → multi_puzzle_solver-0.9.18}/src/puzzle_solver/puzzles/inertia/parse_map/parse_map.py +0 -0
  34. {multi_puzzle_solver-0.9.15 → multi_puzzle_solver-0.9.18}/src/puzzle_solver/puzzles/inertia/tsp.py +0 -0
  35. {multi_puzzle_solver-0.9.15 → multi_puzzle_solver-0.9.18}/src/puzzle_solver/puzzles/kakurasu/kakurasu.py +0 -0
  36. {multi_puzzle_solver-0.9.15 → multi_puzzle_solver-0.9.18}/src/puzzle_solver/puzzles/keen/keen.py +0 -0
  37. {multi_puzzle_solver-0.9.15 → multi_puzzle_solver-0.9.18}/src/puzzle_solver/puzzles/light_up/light_up.py +0 -0
  38. {multi_puzzle_solver-0.9.15 → multi_puzzle_solver-0.9.18}/src/puzzle_solver/puzzles/lits/lits.py +0 -0
  39. {multi_puzzle_solver-0.9.15 → multi_puzzle_solver-0.9.18}/src/puzzle_solver/puzzles/magnets/magnets.py +0 -0
  40. {multi_puzzle_solver-0.9.15 → multi_puzzle_solver-0.9.18}/src/puzzle_solver/puzzles/map/map.py +0 -0
  41. {multi_puzzle_solver-0.9.15 → multi_puzzle_solver-0.9.18}/src/puzzle_solver/puzzles/minesweeper/minesweeper.py +0 -0
  42. {multi_puzzle_solver-0.9.15 → multi_puzzle_solver-0.9.18}/src/puzzle_solver/puzzles/mosaic/mosaic.py +0 -0
  43. {multi_puzzle_solver-0.9.15 → multi_puzzle_solver-0.9.18}/src/puzzle_solver/puzzles/nonograms/nonograms.py +0 -0
  44. {multi_puzzle_solver-0.9.15 → multi_puzzle_solver-0.9.18}/src/puzzle_solver/puzzles/pearl/pearl.py +0 -0
  45. {multi_puzzle_solver-0.9.15 → multi_puzzle_solver-0.9.18}/src/puzzle_solver/puzzles/range/range.py +0 -0
  46. {multi_puzzle_solver-0.9.15 → multi_puzzle_solver-0.9.18}/src/puzzle_solver/puzzles/signpost/signpost.py +0 -0
  47. {multi_puzzle_solver-0.9.15 → multi_puzzle_solver-0.9.18}/src/puzzle_solver/puzzles/singles/singles.py +0 -0
  48. {multi_puzzle_solver-0.9.15 → multi_puzzle_solver-0.9.18}/src/puzzle_solver/puzzles/star_battle/star_battle.py +0 -0
  49. {multi_puzzle_solver-0.9.15 → multi_puzzle_solver-0.9.18}/src/puzzle_solver/puzzles/star_battle/star_battle_shapeless.py +0 -0
  50. {multi_puzzle_solver-0.9.15 → multi_puzzle_solver-0.9.18}/src/puzzle_solver/puzzles/stitches/stitches.py +0 -0
  51. {multi_puzzle_solver-0.9.15 → multi_puzzle_solver-0.9.18}/src/puzzle_solver/puzzles/sudoku/sudoku.py +0 -0
  52. {multi_puzzle_solver-0.9.15 → multi_puzzle_solver-0.9.18}/src/puzzle_solver/puzzles/tents/tents.py +0 -0
  53. {multi_puzzle_solver-0.9.15 → multi_puzzle_solver-0.9.18}/src/puzzle_solver/puzzles/thermometers/thermometers.py +0 -0
  54. {multi_puzzle_solver-0.9.15 → multi_puzzle_solver-0.9.18}/src/puzzle_solver/puzzles/towers/towers.py +0 -0
  55. {multi_puzzle_solver-0.9.15 → multi_puzzle_solver-0.9.18}/src/puzzle_solver/puzzles/tracks/tracks.py +0 -0
  56. {multi_puzzle_solver-0.9.15 → multi_puzzle_solver-0.9.18}/src/puzzle_solver/puzzles/undead/undead.py +0 -0
  57. {multi_puzzle_solver-0.9.15 → multi_puzzle_solver-0.9.18}/src/puzzle_solver/puzzles/unruly/unruly.py +0 -0
  58. {multi_puzzle_solver-0.9.15 → multi_puzzle_solver-0.9.18}/src/puzzle_solver/utils/visualizer.py +0 -0
  59. {multi_puzzle_solver-0.9.15 → multi_puzzle_solver-0.9.18}/tests/test_aquarium.py +0 -0
  60. {multi_puzzle_solver-0.9.15 → multi_puzzle_solver-0.9.18}/tests/test_battleships.py +0 -0
  61. {multi_puzzle_solver-0.9.15 → multi_puzzle_solver-0.9.18}/tests/test_black_box.py +0 -0
  62. {multi_puzzle_solver-0.9.15 → multi_puzzle_solver-0.9.18}/tests/test_bridges.py +0 -0
  63. {multi_puzzle_solver-0.9.15 → multi_puzzle_solver-0.9.18}/tests/test_chess_melee.py +0 -0
  64. {multi_puzzle_solver-0.9.15 → multi_puzzle_solver-0.9.18}/tests/test_chess_range.py +0 -0
  65. {multi_puzzle_solver-0.9.15 → multi_puzzle_solver-0.9.18}/tests/test_chess_solo.py +0 -0
  66. {multi_puzzle_solver-0.9.15 → multi_puzzle_solver-0.9.18}/tests/test_dominosa.py +0 -0
  67. {multi_puzzle_solver-0.9.15 → multi_puzzle_solver-0.9.18}/tests/test_filling.py +0 -0
  68. {multi_puzzle_solver-0.9.15 → multi_puzzle_solver-0.9.18}/tests/test_guess.py +0 -0
  69. {multi_puzzle_solver-0.9.15 → multi_puzzle_solver-0.9.18}/tests/test_inertia.py +0 -0
  70. {multi_puzzle_solver-0.9.15 → multi_puzzle_solver-0.9.18}/tests/test_kakurasu.py +0 -0
  71. {multi_puzzle_solver-0.9.15 → multi_puzzle_solver-0.9.18}/tests/test_keen.py +0 -0
  72. {multi_puzzle_solver-0.9.15 → multi_puzzle_solver-0.9.18}/tests/test_light_up.py +0 -0
  73. {multi_puzzle_solver-0.9.15 → multi_puzzle_solver-0.9.18}/tests/test_lits.py +0 -0
  74. {multi_puzzle_solver-0.9.15 → multi_puzzle_solver-0.9.18}/tests/test_magnets.py +0 -0
  75. {multi_puzzle_solver-0.9.15 → multi_puzzle_solver-0.9.18}/tests/test_map.py +0 -0
  76. {multi_puzzle_solver-0.9.15 → multi_puzzle_solver-0.9.18}/tests/test_minesweeper.py +0 -0
  77. {multi_puzzle_solver-0.9.15 → multi_puzzle_solver-0.9.18}/tests/test_mosaic.py +0 -0
  78. {multi_puzzle_solver-0.9.15 → multi_puzzle_solver-0.9.18}/tests/test_nonograms.py +0 -0
  79. {multi_puzzle_solver-0.9.15 → multi_puzzle_solver-0.9.18}/tests/test_pearl.py +0 -0
  80. {multi_puzzle_solver-0.9.15 → multi_puzzle_solver-0.9.18}/tests/test_range.py +0 -0
  81. {multi_puzzle_solver-0.9.15 → multi_puzzle_solver-0.9.18}/tests/test_signpost.py +0 -0
  82. {multi_puzzle_solver-0.9.15 → multi_puzzle_solver-0.9.18}/tests/test_singles.py +0 -0
  83. {multi_puzzle_solver-0.9.15 → multi_puzzle_solver-0.9.18}/tests/test_star_battle.py +0 -0
  84. {multi_puzzle_solver-0.9.15 → multi_puzzle_solver-0.9.18}/tests/test_stitches.py +0 -0
  85. {multi_puzzle_solver-0.9.15 → multi_puzzle_solver-0.9.18}/tests/test_sudoku.py +0 -0
  86. {multi_puzzle_solver-0.9.15 → multi_puzzle_solver-0.9.18}/tests/test_tents.py +0 -0
  87. {multi_puzzle_solver-0.9.15 → multi_puzzle_solver-0.9.18}/tests/test_thermometers.py +0 -0
  88. {multi_puzzle_solver-0.9.15 → multi_puzzle_solver-0.9.18}/tests/test_towers.py +0 -0
  89. {multi_puzzle_solver-0.9.15 → multi_puzzle_solver-0.9.18}/tests/test_tracks.py +0 -0
  90. {multi_puzzle_solver-0.9.15 → multi_puzzle_solver-0.9.18}/tests/test_undead.py +0 -0
  91. {multi_puzzle_solver-0.9.15 → multi_puzzle_solver-0.9.18}/tests/test_unruly.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: multi-puzzle-solver
3
- Version: 0.9.15
3
+ Version: 0.9.18
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
@@ -39,22 +39,35 @@ pip install multi-puzzle-solver
39
39
  Use:
40
40
 
41
41
  ```python
42
- from puzzle_solver import nonograms_solver
43
- solver = nonograms_solver.Board(top=[[2], [3], [1], [1, 1]], side=[[3], [1], [2, 1], [1]])
44
- solutions = solver.solve_and_print()
42
+ from puzzle_solver import nonograms_solver as solver
43
+ 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]]
44
+ 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]]
45
+ binst = solver.Board(top=top_numbers, side=side_numbers)
46
+ solutions = binst.solve_and_print()
45
47
  ```
46
48
 
47
49
  Output:
48
50
 
49
51
  ```python
50
52
  Solution found
51
- [[' ' 'B' 'B' 'B']
52
- [' ' 'B' ' ' ' ']
53
- ['B' 'B' ' ' 'B']
54
- ['B' ' ' ' ' ' ']]
53
+ [['B' 'B' 'B' 'B' 'B' 'B' 'B' ' ' 'B' 'B' 'B' ' ' ' ' ' ' ' ']
54
+ ['B' 'B' 'B' 'B' 'B' 'B' 'B' ' ' ' ' ' ' ' ' ' ' 'B' ' ' 'B']
55
+ ['B' 'B' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' 'B' 'B' 'B' ' ']
56
+ ['B' 'B' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' 'B' 'B' 'B']
57
+ ['B' 'B' 'B' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' 'B' 'B']
58
+ ['B' ' ' ' ' ' ' 'B' ' ' 'B' ' ' ' ' 'B' ' ' ' ' ' ' 'B' 'B']
59
+ ['B' ' ' ' ' ' ' ' ' ' ' 'B' 'B' 'B' 'B' 'B' 'B' ' ' ' ' 'B']
60
+ ['B' ' ' ' ' ' ' ' ' ' ' 'B' 'B' 'B' 'B' 'B' 'B' 'B' 'B' 'B']
61
+ [' ' ' ' ' ' ' ' ' ' 'B' 'B' 'B' 'B' 'B' 'B' 'B' 'B' 'B' ' ']
62
+ [' ' ' ' ' ' ' ' ' ' 'B' 'B' ' ' 'B' 'B' 'B' 'B' ' ' ' ' ' ']
63
+ [' ' ' ' ' ' ' ' 'B' 'B' 'B' 'B' 'B' 'B' 'B' 'B' ' ' ' ' ' ']
64
+ ['B' 'B' 'B' 'B' 'B' 'B' 'B' 'B' 'B' 'B' 'B' ' ' ' ' ' ' ' ']
65
+ ['B' 'B' 'B' 'B' 'B' 'B' 'B' ' ' ' ' 'B' ' ' 'B' ' ' ' ' ' ']
66
+ [' ' 'B' 'B' 'B' 'B' ' ' ' ' ' ' ' ' 'B' 'B' 'B' ' ' ' ' ' ']
67
+ [' ' 'B' 'B' 'B' ' ' ' ' ' ' ' ' ' ' ' ' ' ' 'B' 'B' ' ' ' ']]
55
68
  Solutions found: 1
56
69
  status: OPTIMAL
57
- Time taken: 0.00 seconds
70
+ Time taken: 0.04 seconds
58
71
  ```
59
72
  (Note: Printing can be turned off by setting `verbose=False`)
60
73
 
@@ -269,6 +282,23 @@ These are all the puzzles that are implemented in this repo. <br> Click on any o
269
282
  <img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/black_box_solved.png" alt="Black Box" width="140">
270
283
  </a>
271
284
  </td>
285
+ <td align="center">
286
+ <a href="#galaxies-puzzle-type-35"><b>Galaxies</b><br><br>
287
+ <img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/galaxies_solved.png" alt="Galaxies" width="140">
288
+ </a>
289
+ </td>
290
+ </tr>
291
+ <tr>
292
+ <td align="center">
293
+ <a href="#slant-puzzle-type-36"><b>Slant</b><br><br>
294
+ <img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/slant_solved.png" alt="Slant" width="140">
295
+ </a>
296
+ </td>
297
+ <td align="center">
298
+ <a href="#unequal-puzzle-type-37"><b>Unequal</b><br><br>
299
+ <img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/unequal_solved.png" alt="Unequal" width="140">
300
+ </a>
301
+ </td>
272
302
  </tr>
273
303
  </table>
274
304
 
@@ -318,6 +348,9 @@ These are all the puzzles that are implemented in this repo. <br> Click on any o
318
348
  - [Star Battle Shapeless (Puzzle Type #32)](#star-battle-shapeless-puzzle-type-32)
319
349
  - [Lits (Puzzle Type #33)](#lits-puzzle-type-33)
320
350
  - [Black Box (Puzzle Type #34)](#black-box-puzzle-type-34)
351
+ - [Galaxies (Puzzle Type #35)](#galaxies-puzzle-type-35)
352
+ - [Slant (Puzzle Type #36)](#slant-puzzle-type-36)
353
+ - [Unequal (Puzzle Type #37)](#unequal-puzzle-type-37)
321
354
  - [Why SAT / CP-SAT?](#why-sat--cp-sat)
322
355
  - [Testing](#testing)
323
356
  - [Contributing](#contributing)
@@ -1772,8 +1805,8 @@ Thus the solver was developed with the additional much harder goal of collecting
1772
1805
  It does so using the following high level steps:
1773
1806
 
1774
1807
  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.
1775
- 2. Model step (1) as a [Generalized Traveling Salesman Problem (GTSP)](https://en.wikipedia.org/wiki/Set_TSP_problem), where each gems edge group forms a cluster.
1776
- 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).)
1808
+ 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.
1809
+ 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).)
1777
1810
  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.
1778
1811
 
1779
1812
  This achieves a final sequence of moves that is empirically always faster than the website's solution.
@@ -2892,6 +2925,251 @@ Time taken: 30.33 seconds
2892
2925
 
2893
2926
  ---
2894
2927
 
2928
+ ## Galaxies (Puzzle Type #35)
2929
+
2930
+ * [**Play online**](https://www.chiark.greenend.org.uk/~sgtatham/puzzles/js/galaxies.html)
2931
+
2932
+ * [**Instructions**](https://www.chiark.greenend.org.uk/~sgtatham/puzzles/doc/galaxies.html#galaxies)
2933
+
2934
+ * [**Solver Code**][35]
2935
+
2936
+ <details>
2937
+ <summary><strong>Rules</strong></summary>
2938
+
2939
+ 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.
2940
+
2941
+ 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.
2942
+
2943
+ </details>
2944
+
2945
+ **Unsolved puzzle**
2946
+
2947
+ <img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/galaxies_unsolved.png" alt="Galaxies unsolved" width="500">
2948
+
2949
+ Code to utilize this package and solve the puzzle:
2950
+
2951
+ Note: The number are arbitrary and simply number each galaxy as an integer.
2952
+
2953
+ ```python
2954
+ from puzzle_solver import galaxies_solver as solver
2955
+ galaxies = np.array([
2956
+ [' ', ' ', '00', ' ', ' ', '01', '01', '02', '02', '03', '03', ' ', '04', '04', ' '],
2957
+ ['05', '05', ' ', ' ', '06', '01', '01', '02', '02', ' ', ' ', ' ', '07', ' ', ' '],
2958
+ ['08', ' ', ' ', ' ', '06', ' ', '09', '09', ' ', ' ', '10', ' ', ' ', ' ', ' '],
2959
+ [' ', ' ', ' ', ' ', ' ', ' ', '11', '11', '12', ' ', ' ', ' ', ' ', '13', '13'],
2960
+ ['14', ' ', ' ', ' ', '15', ' ', '11', '11', ' ', ' ', ' ', ' ', '16', ' ', ' '],
2961
+ [' ', '17', ' ', ' ', '15', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '16', ' ', '18'],
2962
+ [' ', '17', '19', ' ', ' ', ' ', ' ', ' ', ' ', '20', ' ', ' ', ' ', '21', '18'],
2963
+ [' ', '22', ' ', ' ', '23', ' ', ' ', ' ', ' ', '20', ' ', '24', '24', '21', '25'],
2964
+ ['26', '27', '27', '28', '28', '29', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '30', '30'],
2965
+ [' ', '27', '27', '28', '28', '31', '31', ' ', ' ', ' ', ' ', '32', ' ', '30', '30'],
2966
+ [' ', ' ', ' ', '33', '33', '31', '31', '34', ' ', ' ', '35', ' ', ' ', ' ', ' '],
2967
+ ['36', ' ', ' ', '33', '33', ' ', ' ', '34', ' ', ' ', ' ', ' ', ' ', '37', ' '],
2968
+ [' ', ' ', '38', '38', ' ', '39', ' ', '40', '40', '41', '41', '42', ' ', '37', ' '],
2969
+ ['43', '44', '38', '38', '45', '45', '46', '40', '40', '41', '41', '42', ' ', ' ', ' '],
2970
+ ['43', ' ', ' ', ' ', ' ', ' ', ' ', '47', ' ', ' ', ' ', ' ', '48', '48', ' ']
2971
+ ])
2972
+ binst = solver.Board(galaxies=galaxies)
2973
+ solutions = binst.solve_and_print()
2974
+ ```
2975
+ **Script Output**
2976
+
2977
+ As the instructions say, the solution to this puzzle is not garunteed to be unique.
2978
+
2979
+ ```python
2980
+ Solution found
2981
+ [
2982
+ ['00', '00', '00', '00', '00', '01', '01', '02', '02', '03', '03', '04', '04', '04', '04'],
2983
+ ['05', '05', '15', '06', '06', '01', '01', '02', '02', '10', '10', '07', '07', '07', '13'],
2984
+ ['08', '15', '15', '15', '06', '06', '09', '09', '10', '10', '10', '10', '10', '13', '13'],
2985
+ ['14', '15', '15', '15', '15', '15', '11', '11', '12', '20', '10', '10', '16', '13', '13'],
2986
+ ['14', '15', '15', '15', '15', '15', '11', '11', '20', '20', '20', '20', '16', '13', '13'],
2987
+ ['14', '17', '17', '15', '15', '15', '15', '15', '20', '20', '20', '20', '16', '13', '18'],
2988
+ ['17', '17', '19', '15', '15', '15', '15', '15', '20', '20', '20', '24', '16', '21', '18'],
2989
+ ['26', '22', '27', '27', '23', '15', '15', '15', '20', '20', '20', '24', '24', '21', '25'],
2990
+ ['26', '27', '27', '28', '28', '29', '15', '20', '20', '20', '20', '32', '24', '30', '30'],
2991
+ ['26', '27', '27', '28', '28', '31', '31', '20', '20', '20', '20', '32', '37', '30', '30'],
2992
+ ['27', '27', '33', '33', '33', '31', '31', '34', '34', '20', '35', '32', '37', '37', '37'],
2993
+ ['36', '38', '38', '33', '33', '33', '34', '34', '41', '41', '41', '41', '37', '37', '37'],
2994
+ ['44', '44', '38', '38', '45', '39', '46', '40', '40', '41', '41', '42', '37', '37', '37'],
2995
+ ['43', '44', '38', '38', '45', '45', '46', '40', '40', '41', '41', '42', '37', '37', '37'],
2996
+ ['43', '44', '44', '38', '38', '45', '46', '47', '41', '41', '41', '41', '48', '48', '37'],
2997
+ ]
2998
+ Solutions found: 1
2999
+ status: OPTIMAL
3000
+ Time taken: 0.07 seconds
3001
+ ```
3002
+
3003
+ **Solved puzzle**
3004
+
3005
+ Applying the solution to the puzzle visually:
3006
+
3007
+ <img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/galaxies_solved.png" alt="Galaxies solved" width="500">
3008
+
3009
+ ---
3010
+
3011
+ ## Slant (Puzzle Type #36)
3012
+
3013
+ * [**Play online**](https://www.chiark.greenend.org.uk/~sgtatham/puzzles/js/slant.html)
3014
+
3015
+ * [**Instructions**](https://www.chiark.greenend.org.uk/~sgtatham/puzzles/doc/slant.html#slant)
3016
+
3017
+ * [**Solver Code**][36]
3018
+
3019
+ <details>
3020
+ <summary><strong>Rules</strong></summary>
3021
+
3022
+ You have a grid of squares. Your aim is to draw a diagonal line through each square, and choose which way each line slants so that the following conditions are met:
3023
+
3024
+ - The diagonal lines never form a loop.
3025
+ - Any point with a circled number has precisely that many lines meeting at it. (Thus, a 4 is the centre of a cross shape, whereas a zero is the centre of a diamond shape – or rather, a partial diamond shape, because a zero can never appear in the middle of the grid because that would immediately cause a loop.)
3026
+
3027
+ </details>
3028
+
3029
+ **Unsolved puzzle**
3030
+
3031
+ <img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/slant_unsolved.png" alt="Slant unsolved" width="500">
3032
+
3033
+ Code to utilize this package and solve the puzzle:
3034
+
3035
+ Note: For an NxM board you need an (N+1)x(M+1) array because the puzzle is to solve for the cells while the input is the values at the corners (there's always one more corner than cells in each dimension).
3036
+
3037
+ ```python
3038
+ from puzzle_solver import slant_solver as solver
3039
+ board = np.array([
3040
+ [' ', ' ', '1', ' ', '1', ' ', '1', ' ', '1', ' ', ' ', ' ', ' '],
3041
+ [' ', '1', '2', ' ', ' ', '2', ' ', '2', ' ', '2', ' ', '1', '1'],
3042
+ [' ', '2', '2', ' ', '2', '3', '2', ' ', '3', ' ', ' ', '1', ' '],
3043
+ ['1', '1', ' ', '3', '1', '2', ' ', '1', ' ', ' ', '3', ' ', ' '],
3044
+ [' ', ' ', '1', '1', ' ', ' ', ' ', '1', '1', '3', ' ', '3', ' '],
3045
+ ['1', '2', ' ', '2', '2', ' ', '2', ' ', ' ', '1', '2', ' ', ' '],
3046
+ [' ', '2', '2', '2', ' ', ' ', '2', '3', '2', ' ', ' ', ' ', ' '],
3047
+ [' ', '1', '2', ' ', ' ', '2', ' ', '2', ' ', ' ', ' ', '1', ' '],
3048
+ [' ', ' ', ' ', '3', '2', '2', ' ', '3', '1', ' ', ' ', ' ', '1'],
3049
+ [' ', '2', '1', '1', '2', ' ', '1', ' ', '1', ' ', '1', '1', ' '],
3050
+ [' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '1', ' ', ' '],
3051
+ ])
3052
+ binst = solver.Board(numbers=board)
3053
+ solutions = binst.solve_and_print()
3054
+ ```
3055
+ **Script Output**
3056
+
3057
+ ```python
3058
+ Solution found
3059
+ [
3060
+ [ / \ \ / / / / \ \ \ / \ ]
3061
+ [ \ \ \ \ \ \ / \ / / \ \ ]
3062
+ [ \ \ \ / / \ / \ \ \ \ / ]
3063
+ [ \ / \ \ / \ / / \ / \ / ]
3064
+ [ / \ \ / \ \ \ / / / \ \ ]
3065
+ [ / \ \ / \ \ \ / \ / \ \ ]
3066
+ [ / \ \ / \ / / / \ / / \ ]
3067
+ [ \ \ \ \ \ / / / \ / \ \ ]
3068
+ [ / / / \ \ / / \ \ / \ \ ]
3069
+ [ \ \ / / / \ / \ / \ \ / ]
3070
+ ]
3071
+ Solutions found: 1
3072
+ status: OPTIMAL
3073
+ Time taken: 0.06 seconds
3074
+ ```
3075
+
3076
+ **Solved puzzle**
3077
+
3078
+ Applying the solution to the puzzle visually:
3079
+
3080
+ <img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/slant_solved.png" alt="Slant solved" width="500">
3081
+
3082
+ ---
3083
+
3084
+ ## Unequal (Puzzle Type #37)
3085
+
3086
+ * [**Play online**](https://www.chiark.greenend.org.uk/~sgtatham/puzzles/js/unequal.html)
3087
+
3088
+ * [**Instructions**](https://www.chiark.greenend.org.uk/~sgtatham/puzzles/doc/unequal.html#unequal)
3089
+
3090
+ * [**Solver Code**][37]
3091
+
3092
+ <details>
3093
+ <summary><strong>Rules</strong></summary>
3094
+
3095
+ You have a square grid; each square may contain a digit from 1 to the size of the grid, and some squares have clue signs between them. Your aim is to fully populate the grid with numbers such that:
3096
+
3097
+ - Each row contains only one occurrence of each digit
3098
+ - Each column contains only one occurrence of each digit
3099
+ - All the clue signs are satisfied.
3100
+
3101
+ There are two modes for this game, 'Unequal' and 'Adjacent'.
3102
+
3103
+ In 'Unequal' mode, the clue signs are greater-than symbols indicating one square's value is greater than its neighbour's. In this mode not all clues may be visible, particularly at higher difficulty levels.
3104
+
3105
+ In 'Adjacent' mode, the clue signs are bars indicating one square's value is numerically adjacent (i.e. one higher or one lower) than its neighbour. In this mode all clues are always visible: absence of a bar thus means that a square's value is definitely not numerically adjacent to that neighbour's.
3106
+
3107
+ In 'Trivial' difficulty level (available via the 'Custom' game type selector), there are no greater-than signs in 'Unequal' mode; the puzzle is to solve the Latin square only.
3108
+
3109
+ </details>
3110
+
3111
+ **Unsolved puzzle**
3112
+
3113
+ <img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/unequal_unsolved.png" alt="Unequal unsolved" width="500">
3114
+
3115
+ Code to utilize this package and solve the puzzle:
3116
+
3117
+ Note: For an NxM board you need an (2N-1)x(2M-1) array because the puzzle involves input in between the cells. Each numbered cell has neighbors horizontally to represent ">", "<", and "|" (where "|" represents adjacency) and vertically to represent "∧", "∨" and "-" (where "-" represents adjacency). The "X" in the input are unused corners that shouldnt contain anything (just a corner). The numbers should never appear orthogonal to an "X", only diagonally to it. vice-versa for the comparison operators.
3118
+
3119
+ ```python
3120
+ board = np.array([
3121
+ [' ', ' ', ' ', ' ', '9', ' ', '1', ' ', '7', '>', ' ', '>', ' ', ' ', ' ', ' ', ' ', '>', ' '],
3122
+ [' ', 'X', 'V', 'X', ' ', 'X', ' ', 'X', ' ', 'X', ' ', 'X', '∧', 'X', ' ', 'X', ' ', 'X', ' '],
3123
+ [' ', ' ', ' ', ' ', ' ', ' ', '6', ' ', ' ', ' ', '9', ' ', ' ', ' ', '5', ' ', '3', ' ', ' '],
3124
+ [' ', 'X', ' ', 'X', '∧', 'X', ' ', 'X', '∧', 'X', ' ', 'X', ' ', 'X', ' ', 'X', ' ', 'X', ' '],
3125
+ [' ', ' ', ' ', '>', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '6', ' ', '9', ' ', ' ', ' ', ' '],
3126
+ [' ', 'X', ' ', 'X', 'V', 'X', 'V', 'X', 'V', 'X', ' ', 'X', ' ', 'X', ' ', 'X', ' ', 'X', 'V'],
3127
+ [' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '<', ' ', '<', ' ', '>', ' ', ' ', ' ', ' ', ' '],
3128
+ [' ', 'X', ' ', 'X', '∧', 'X', 'V', 'X', ' ', 'X', ' ', 'X', ' ', 'X', ' ', 'X', ' ', 'X', ' '],
3129
+ [' ', ' ', '3', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '<', ' ', ' ', ' '],
3130
+ [' ', 'X', ' ', 'X', ' ', 'X', ' ', 'X', '∧', 'X', ' ', 'X', ' ', 'X', ' ', 'X', ' ', 'X', ' '],
3131
+ [' ', '<', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '5', ' ', ' ', '>', ' ', '<', ' ', ' ', '4'],
3132
+ ['V', 'X', '∧', 'X', 'V', 'X', ' ', 'X', ' ', 'X', ' ', 'X', ' ', 'X', 'V', 'X', ' ', 'X', ' '],
3133
+ [' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '>', ' ', ' ', ' ', ' ', ' '],
3134
+ [' ', 'X', ' ', 'X', ' ', 'X', ' ', 'X', ' ', 'X', ' ', 'X', '∧', 'X', ' ', 'X', ' ', 'X', 'V'],
3135
+ [' ', ' ', ' ', '<', ' ', ' ', ' ', '<', ' ', ' ', ' ', '<', ' ', '<', ' ', ' ', ' ', '<', ' '],
3136
+ [' ', 'X', ' ', 'X', ' ', 'X', 'V', 'X', ' ', 'X', 'V', 'X', '∧', 'X', ' ', 'X', ' ', 'X', ' '],
3137
+ [' ', ' ', ' ', ' ', ' ', '>', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '>', ' ', ' ', '9', ' ', ' '],
3138
+ ['V', 'X', ' ', 'X', ' ', 'X', ' ', 'X', ' ', 'X', ' ', 'X', ' ', 'X', ' ', 'X', ' ', 'X', 'V'],
3139
+ [' ', '>', ' ', ' ', ' ', '>', ' ', ' ', ' ', ' ', '4', '<', ' ', '<', ' ', '<', '7', ' ', '2'],
3140
+ ])
3141
+ binst = solver.Board(board=board)
3142
+ solutions = binst.solve_and_print()
3143
+ ```
3144
+ **Script Output**
3145
+
3146
+ ```python
3147
+ Solution found
3148
+ [
3149
+ [ 6 5 9 1 7 2 0 8 4 3 ]
3150
+ [ 7 1 0 6 4 9 2 5 3 8 ]
3151
+ [ 3 4 2 8 5 0 6 9 1 7 ]
3152
+ [ 5 9 1 7 3 6 8 4 2 0 ]
3153
+ [ 8 3 5 4 0 7 1 2 6 9 ]
3154
+ [ 2 6 7 0 1 5 9 3 8 4 ]
3155
+ [ 0 7 4 9 2 8 3 1 5 6 ]
3156
+ [ 9 2 6 5 8 3 4 7 0 1 ]
3157
+ [ 4 8 3 2 6 1 7 0 9 5 ]
3158
+ [ 1 0 8 3 9 4 5 6 7 2 ]
3159
+ ]
3160
+ Solutions found: 1
3161
+ status: OPTIMAL
3162
+ Time taken: 0.05 seconds
3163
+ ```
3164
+
3165
+ **Solved puzzle**
3166
+
3167
+ Applying the solution to the puzzle visually:
3168
+
3169
+ <img src="https://raw.githubusercontent.com/Ar-Kareem/puzzle_solver/master/images/unequal_solved.png" alt="Unequal solved" width="500">
3170
+
3171
+ ---
3172
+
2895
3173
  ---
2896
3174
 
2897
3175
  ## Why SAT / CP-SAT?
@@ -2977,3 +3255,6 @@ Issues and PRs welcome!
2977
3255
  [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"
2978
3256
  [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
3257
  [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"
3258
+ [35]: https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/galaxies "puzzle_solver/src/puzzle_solver/puzzles/galaxies at master · Ar-Kareem/puzzle_solver · GitHub"
3259
+ [36]: https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/slant "puzzle_solver/src/puzzle_solver/puzzles/slant at master · Ar-Kareem/puzzle_solver · GitHub"
3260
+ [37]: https://github.com/Ar-Kareem/puzzle_solver/tree/master/src/puzzle_solver/puzzles/unequal "puzzle_solver/src/puzzle_solver/puzzles/unequal at master · Ar-Kareem/puzzle_solver · GitHub"