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

If you want a printable version of this puzzle click here
If you want a printable version of this puzzle click here Photograph: nick berry

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.

If you want a printable version of this puzzle click here
If you want a printable version of this puzzle click here Photograph: Bernardo Recamán

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

UPDATE: Read the solutions here.

Meanwhile, please discuss your favourite Hamiltons.

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.

LLPB paperback

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

Contributor

Alex Bellos

The GuardianTramp

Related Content

Article image
Did you solve it? Hamiltonian ingenuity on the grid
The solutions to today’s puzzles

Alex Bellos

18, Oct, 2021 @4:00 PM

Article image
Did you solve it? Puzzlebombed!
The solutions to today’s teasers

Alex Bellos

21, Sep, 2020 @4:00 PM

Article image
Can you solve it? Puzzlebombed!
Bamboozling bar graphs and brain busting bees

Alex Bellos

21, Sep, 2020 @6:10 AM

Article image
Can you solve it? Domino dancing
A riddle about rectangles

Alex Bellos

15, Jun, 2020 @6:10 AM

Article image
Did you solve it? Domino dancing
The solution to today’s puzzle

Alex Bellos

15, Jun, 2020 @4:00 PM

Article image
Can you solve it? Clueless sudoku
Puzzles where less is more

Alex Bellos

26, Jul, 2021 @6:10 AM

Article image
Did you solve it? Logical philosophers
The solutions to today’s puzzles

Alex Bellos

23, Aug, 2021 @4:00 PM

Article image
Can you solve it? Double chocolate!
A delicious new puzzle from Japan

Alex Bellos

06, Apr, 2020 @6:10 AM

Article image
Did you solve it? Double chocolate!
The solutions to today’s puzzles

Alex Bellos

06, Apr, 2020 @4:00 PM

Article image
Can you solve it? Logical philosophers
Five existentialists walk into a bar.

Alex Bellos

23, Aug, 2021 @6:21 AM