Algorithms & constraints / Independent algorithm study
Hooks Solver
An OCaml program that searches for a board shape and pentomino tiling under a set of puzzle rules.
View source code- OCaml
- Dune
- Unix

01 / The problem
The problem
The puzzle asks which cells should be filled and how the pieces fit. Region labels, connected cells, and clues along the board’s edges all affect the answer.
02 / What was built
What was built
The command-line program tries label assignments, selects cells within hook regions, and searches for a tiling using distinct pentominoes. It generates piece orientations and checks candidate shapes against the puzzle rules.
03 / Engineering decisions
Engineering decisions
Remove duplicate orientations
Rotated and reflected pieces are moved to a common origin and sorted. Matching orientations are removed before board placements are generated.
Search in three stages
The program assigns labels, selects cells, and tries a tiling. Piece placements must stay within selected cells, avoid overlap, and use distinct piece types.
Check rules as candidates develop
Cell selection checks connectivity and filled 2×2 blocks. Completed tilings are checked for label sums divisible by five and the outside clues.
04 / Scope
Scope
05 / Read the code
Source code
Reviewed September 10, 2026.