Bite 3.5.12 · Modelling Challenges

Building bridges with linear optimization, the Hashi puzzle

From a Japanese puzzle to a single-commodity flow model

Image by Kjell-Jostein Sivertsen · Unsplash

Hashi (short for Hashiwokakero, which means building bridges) is a popular logic puzzle played on a rectangular grid featuring islands represented by numbered circles. The goal of the game is to connect all the islands using bridges while satisfying a set of formal constraints:

  1. Alignment: Bridges can only be drawn horizontally or vertically between islands aligned in the same row or column, with no other islands in between.
  2. Connection capacity: At most two bridges can be built between any pair of neighboring islands.
  3. No intersection: Bridges cannot cross each other.
  4. Fixed degree: Each island must have a total number of connected bridges exactly equal to the number indicated inside it.
  5. Single connected network: All islands must end up connected within a single connected component (a continuous transportation network).

Below is an example of a Hashi board consisting of $52$ islands:

Would you like to try connecting the islands logically before checking the solution and the optimization model formulation?


The Hashi puzzle can be formulated as a mixed-integer linear programming model using a network flow approach to guarantee full connectivity.

Keep following the series

← Previous · 3.5.11Knight's Tour on the Chess Board Modelling Challenges Next · 3.5.13 →Number Sums

How to cite

Cite this post

Martín-Campo, F. Javier (2026). Building bridges with linear optimization, the Hashi puzzle. https://www.fjmartincampo.com/blog/2026/hashi/

As a BibTeX entry:

@misc{martín-campo2026building-bridges-with-linear-optimization-the-hashi-puzzle,
  title   = {Building bridges with linear optimization, the Hashi puzzle},
  author  = {Martín-Campo, F. Javier},
  year    = {2026},
  month   = {jul},
  url     = {https://www.fjmartincampo.com/blog/2026/hashi/}
}

This post is published under a CC BY-NC-SA 4.0 license.