Puzzle Kit
This repository provides 100+ useful, efficient and problem‑specific solvers for a variety of logic puzzles. The underlying solving engine is the open‑source Google OR-Tools CP-SAT solver. For more details of puzzles and their input format, you can refer to docs of puzzlekit.
For simplicity, the dataset is removed to puzzlekit-dataset repo. The structured dataset contains 41k+ instances covering 130+ specific and popular puzzle types (e.g. Nonogram, Slitherlink, Akari, Fillomino, Hitori, Kakuro, Kakuro), mostly from Raetsel’s Janko and puzz.link. The details are listed in the table below.
This repo also provides bidirectional conversion between puzz.link and Penpa+ puzzle URLs for supported genres (19 for now) via a shared intermediate representation. puzz.link-like links from common mirrors (e.g., pzplus.tck.mn, pzv.jp) are also accepted.
Table of puzzles, datasets and solvers.
#.P and #.S indicate the number of puzzles and solutions of specific puzzle type respectively.
Max Size shows the maximum scale of collected puzzles.
Sol? shows if the solver has been implemented currently.
Avg T and Max T indicates the average / maximum time required to solve one puzzle grid among all instances (in seconds).
#.V shows the number of verified solutions compared with the expected solutions. Note that some of solutions failed this mainly because of additional yet unpopular constraints (like diagnonal-ABCEndView, which is a bit rare), or different variants of puzzles(like different shapes of 6x6 Jigsaw Sudoku and Bricks puzzle).
Supported puzzle types for URL interchange
(canonical IR name, puzz.link token, aliases, Penpa genre tag)
| Canonical (IR) |
puzz.link token |
puzz.link aliases |
Penpa genre tag |
aqre |
aqre |
aqre |
aqre |
ayeheya |
ayeheya |
ayeheya |
ayeheya (ekawayeh) |
castle |
castle |
castle |
castlewall |
country |
country |
country |
country road |
hebi |
hebi |
hebi, snakes |
hebi-ichigo |
heyawake |
heyawake |
heyawake, heyawacky, heyawack |
heyawake |
kurochute |
kurochute |
kurochute, kuroshuto, kurochuto |
kurochute |
kurodoko |
kurodoko |
kurodoko |
kurodoko |
kurotto |
kurotto |
kurotto |
kurotto |
masyu |
masyu |
masyu, mashu, pearl |
masyu |
moonsun |
moonsun |
moonsun |
moon or sun |
nonogram |
nonogram |
nonogram |
nonogram |
nurikabe |
nurikabe |
nurikabe |
nurikabe |
nurimisaki |
nurimisaki |
nurimisaki |
nurimisaki |
shikaku |
shikaku |
shikaku |
shikaku |
shimaguni |
shimaguni |
shimaguni |
shimaguni (islands) |
slitherlink |
slither |
slitherlink |
slitherlink |
stostone |
stostone |
stostone |
stostone |
yajilin |
yajilin |
yajilin, yajirin |
yajilin |
Gallery of some puzzles (not complete!)


If you are looking for online playing or a browser-based solver with excellent performance, here are some fantastic alternatives:
- Noqx 🎉, with interactive penpa-edit style web interface: An enhanced and more-efficient logic puzzle solver based on Clingo (Answer Set Program (ASP) solver) and WASM. It supports 170+ puzzle types, covering most of this repo with same or even better efficiency compared with this repo. It’s highly recommend to give it a try.
- nikoli-puzzle-solver (Z3): Another SAT-based solver with interactive penpa-style web page via z3 solver for 100+ puzzle types. It supports more grid format like hex, triangle and more.
- puzzle_solver for 90+puzzles by Ar-Kareem, also in OR-Tools.
- Puzzles-Solver in action by newtomsoft, with browser plugins provided.
How Puzzlekit differs:
Puzzlekit is designed as a Python library (WIP… though) for developers and researchers, offering programmatic access, a unified API, and a massive structured dataset for benchmarking.
Usage
Dependencies: Python >= 3.10, e.g.,
conda create -n py310 python=3.10.14
install the solvers via pip:
pip install puzzlekit
Then a quick tour:
import puzzlekit
problem_str = """
10 10
- - - - - b - - - -
- b - - w - - b - -
w - - - - - - - - -
- - - - - - - - w -
- - - - - b b - b -
- w - w w - - - - -
- w - - - - - - - -
- - - - - - - - - b
- - b - - b - - w -
- - - - w - - - - -
"""
res = puzzlekit.solve(problem_str, "masyu")
# res.show() # If you want to visualize it.
The detailed usage of specific logic puzzles can be found in the docs of puzzlekit.
If you want a batch-run, clone the dataset you need via puzzlekit-dataset to ./assets folder in the root. Then run the scripts/benchmark.py like:
python scripts/benchmark.py -p Hidoku
The script will create ./benchmark_results folder where two files, benchmark_{timestamp}.csv and README_STATS_{puzzle_name}_{timestamp}.md can show you the details.
If you want to run all instances, use:
python scripts/benchmark.py -a
Currently it will take ~30 min to solve all 30k+ instances available.
If you want to try the bi-directional conversion between penpa+ and puzz.link, follow the quick tour:
import puzzlekit
# 1st method
ir = puzzlekit.decode("https://puzz.link/p?slither/10/10/g188227cl1dg367bdcg3ddgbhdgd1agbd760dg2cl633661d")
penpa_url = puzzlekit.encode(ir, "penpa")
print(penpa_url)
# get:
# https://swaroopg92.github.io/penpa-edit/#m=edit&p=7VdtT9swEP7Or0...
# 2nd method (recommend)
penpa_url = "YOUR_PENPA_URL" # both full URL or `m=edit&p=...` are okay
puzzlink_url = puzzlekit.convert(penpa_url, "puzzlink")
print(puzzlink_url)
# get:
# https://puzz.link/p?slither/10/10/b86ag68dg127bg62aldg8dad8bgdl26dg722cg68dg88b3
See also scripts/quick_start.py for a runnable sample.
Roadmap
Reference
Aside from links mentioned above, please refer to the following:
Solving Tools:
Dataset and online play:
评论