Snake Pellets

Each square on a 5 x 5 grid--except for the central square--has a food pellet in it. A long, thick snake crawls out of the hole in the central square and moves around the grid, collecting the pellets.

The snake is so thick (almost 1-block thick) that it cannot move past a cell which is already occupied by part of his body. For example, in the diagram, the snake can only collect the 12 food pellets above and right of the central square, ultimately being stuck in the upper right corner since it cannot go any further.

Starting afresh, can the snake cleverly find its way to all 24 of the pellets?


Details and Assumptions:

  • The snake is so long that its tail always stays in the hole no matter how far it travels collecting the pellets.
  • Think of the snake as the snake from the snake game .
No, it will always get stuck Yes, it can

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

3 solutions

Stephen Mellor
Sep 16, 2017

There are multiple solutions, compounded by the fact that the grid is symmetrical

Here is one such solution:

Does there exist a solution for any grid of size 2 k + 1 × 2 k + 1 2k + 1 \times 2k + 1 ?

Agnishom Chattopadhyay - 3 years, 8 months ago

Log in to reply

Yes, as an alternative method to the one shown in the diagram would be to go in a spiral. This makes it possible for any n × n n \times n grid, although admittedly, when n n is even, the snake then starts from one of the four central squares.

Stephen Mellor - 3 years, 8 months ago
Gregory Lewis
Sep 16, 2017
1
2
3
4
5
6
while (canMove()) {
    advance (1):
    if (canMoveLeft()) {
        turnLeft();
    }
}

Why does this algorithm work?

Agnishom Chattopadhyay - 3 years, 8 months ago

How did you make the grey shaded box?

Munem Shahriar - 3 years, 8 months ago

What is it?

Ong Zi Qian - 3 years, 6 months ago
Sumukh Bansal
Sep 16, 2017

Does there exist a solution for any grid of size 2 k + 1 × 2 k + 1 2k + 1 \times 2k + 1 ?

Agnishom Chattopadhyay - 3 years, 8 months ago

Log in to reply

Yes, expand the spiral shown above outwards.

Denton Young - 2 years, 6 months ago

Yes as it as the grid will have same number of rows and columns

Sumukh Bansal - 3 years, 8 months ago

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...