Bite 3.5.6 · Modelling Challenges

The Hidato Number Maze

Mathematical formulation of Hidato through optimization

Image by Onur Kurt · Unsplash

Hidato (also known as Hidoku) is a popular logic puzzle invented by Israeli mathematician Dr. Gyora Benedek. At first glance, it might remind you of Sudoku or a number maze, but its core dynamic relies on constructing a continuous path through a grid.

The challenge is to fill a $9 \times 9$ board with consecutive numbers from 1 to 81 such that each number is an immediate neighbor of the next—horizontally, vertically, or diagonally.

Given a board of dimensions $R \times C$ (in our case $9 \times 9$, with $N=R \cdot C=81$ cells) where some cells already contain fixed initial values, we must determine the placement of the remaining numbers while satisfying the following rules:

  1. Number range: Each cell must contain a unique integer belonging to the set ${1, 2, \dots, N}$.
  2. 8-neighbor connectivity: Two consecutive numbers $k$ and $k+1$ must be placed in adjacent cells horizontally, vertically, or diagonally (Chebyshev distance equal to 1).
  3. Initial clues: Pre-filled numbers on the starting board must strictly remain in their original positions.
  4. Uniqueness: Each cell contains exactly one number, and each number appears on the board exactly once.

The key question we need to answer is: Is there a valid assignment of positions for the entire sequence from 1 to 81, and how can we find it automatically?

Consider the following example:

Do you dare to solve it logically before taking on the model?


This logic game can be formulated elegantly and systematically as a Binary Linear Optimization problem. Care to give it a try?

Keep following the series

← Previous · 3.5.5Crossing the Bridge Modelling Challenges Next · 3.5.7 →Dominosa

How to cite

Cite this post

Martín-Campo, F. Javier (2026). The Hidato Number Maze. https://www.fjmartincampo.com/blog/2026/hidato/

As a BibTeX entry:

@misc{martín-campo2026the-hidato-number-maze,
  title   = {The Hidato Number Maze},
  author  = {Martín-Campo, F. Javier},
  year    = {2026},
  month   = {jun},
  url     = {https://www.fjmartincampo.com/blog/2026/hidato/}
}

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