# Can you solve it? Hamiltonian ingenuity on the grid

No, not that Hamilton. I meant William Rowan Hamilton, the nineteenth century Irish mathematician.

And not that sort of grid. I meant a square grid, like a chessboard or a Sudoku.

Today’s two puzzles do, however, require you to complete a thrilling journey of daredevil zigs and zags. Hold onto your hats! (Click here for a printable page of the puzzles.)

1. The Hamiltonian path

Place the numbers from 1 to 49 on the grid below such that all consecutive numbers are either horizontal or vertical neighbours. In other words, 1 is horizontally or vertically adjacent to 2, which is horizontally or vertically adjacent to 3, and so on up to 49.

The shaded squares are the prime numbers: 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43 and 47

The solution to the puzzle is what’s known as a Hamiltonian path through the grid, which is a path that passes through every cell exactly once. There are 49 cells and 49 numbers to be placed.

The clue to solving this puzzle is to consider the gaps between the prime numbers (which are those numbers only divisible by themselves and 1). There are four solutions, but they all start and finish on the same cells.

If a Hamiltonian path joins up to make a loop, it is called a Hamiltonian circuit, which is an even better motor racing pun.

2. The Hamiltonian circuit

Place the numbers from 1 to 64 on the grid below such that all consecutive numbers are either horizontal or vertical neighbours, and 1 also is either a horizontal or vertical neighbour of 64. As above, the shaded squares are prime numbers, which are the ones mentioned in the previous puzzle plus 53, 59, and 61.

I’ll be back at 5pm UK with the solutions and some hints. PLEASE NO SPOILERS

Thanks to Nick Berry of DataGenetics for the first puzzle and Bernardo Recamán, author of The Bogotá Puzzles, for the second.

I set a puzzle here every two weeks on a Monday. I’m always on the look-out for great puzzles. If you would like to suggest one, email me. I also give school talks about maths and puzzles (restrictions allowing). If your school is interested please get in touch.

I’m the author of several books of popular science, most recently The Language Lover’s Puzzle Book, just out in paperback.

Alex Bellos

The Guardian

### Related Content

##### Did you solve it? Hamiltonian ingenuity on the grid

Alex Bellos

18, Oct, 2021 @4:00 PM

##### Did you solve it? Puzzlebombed!

Alex Bellos

21, Sep, 2020 @4:00 PM

##### Can you solve it? Puzzlebombed!

Alex Bellos

21, Sep, 2020 @6:10 AM

##### Can you solve it? Domino dancing

Alex Bellos

15, Jun, 2020 @6:10 AM

##### Did you solve it? Domino dancing

Alex Bellos

15, Jun, 2020 @4:00 PM

##### Can you solve it? Clueless sudoku

Alex Bellos

26, Jul, 2021 @6:10 AM

##### Did you solve it? Logical philosophers

Alex Bellos

23, Aug, 2021 @4:00 PM

##### Can you solve it? Double chocolate!

Alex Bellos

06, Apr, 2020 @6:10 AM

##### Did you solve it? Double chocolate!

Alex Bellos

06, Apr, 2020 @4:00 PM

##### Can you solve it? Logical philosophers

Alex Bellos

23, Aug, 2021 @6:21 AM