Building bridges with linear optimization, the Hashi puzzle

Image by Kjell-Jostein Sivertsen retrieved from 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.


Want to keep exploring the world of Operations Research? Discover more posts on the topic here.




If you found this useful, please cite this as:

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

or 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/}
}



Enjoy Reading This Article?

Here are some more articles you might like to read next:

  • A crime has been committed... in a sudoku!
  • The harmony of digits in solving Kakuro
  • Killer Sudoku, the empty board challenge that math can solve
  • Solving the Number Sums board using mathematical optimization
  • The knight's perfect tour, challenge chess with linear optimization