×   Home   Blog   Newsletter   Privacy   Contact Us   About

Hamiltonian Path Puzzle

Below is a 7×7 grid. Starting at a location of your choice, write the number 1 in that cell. Then, write the number 2 in any of the adjacent cells (horizontally or vertically, but not diagonally), then again with 3, until all the numbers 1–49 are connected in a Hamiltonian, snake-like, path.
The restriction is that some squares are shaded red. In these cells (and only these cell), you must make sure that the number written inside is a Prime number. There are 15 primes in the range 1–49 and these are {2,3,5,7,11,13,17,19,23,29,31,37,41,43,47}.
Write the numbers 1-49 in a connected path (horizontally or vertically) so that the red squares contain prime numbers.

More Challenging?

Did you find the first puzzle easy? Below are two similar problems. This time, however, you are also allowed to move diagonally (this also means that the path might ‘cross’ itself. This is totally fine).


You might also like this article on Self Avoiding Walks, and the backbite algorithm for generating Hamiltonian Paths.