← All work

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
Repository flowchart showing input parsing, label permutations, cell selection, shape validation, pentomino tiling, final constraint checks, and solution output.
The search, step by step. Open full-size diagram

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

  • As a puzzle solver, I can load a puzzle definition or use the built-in example.
  • As a programmer, I can follow the search through label assignments, cell selection, and piece placement.
  • As a puzzle solver, I can inspect the grid and piece coordinates when the search finds a candidate.

05 / Read the code

Source code

Reviewed September 10, 2026.