An entry in Fortnightly Topic Challenge #35: Restricted Title 1. Inspired by the title of this xkcd comic, but in no way related or affiliated beyond the shared name.
It's a well known fact that any animal without legs finds it quite impossible to jump. In fact, such creatures can't even leave the ground to pass by another of their kind.
Below is one such pair. A duo of serpents, trapped as it were, on a flat surface. The grammatically challenged among us might even call them...
Snakes on a Plane! 2
[Cue theme music...]
Here's a few other surprising facts about snakes:
- They freaking love apples. Like, it's all they eat.
- Interestingly, whilst they don't necessarily take it in turns eating apples (they sometimes do, but often one snake will eat several apples while the other rests), they're still super fair and overall, will share available apples evenly.
- When a snake eats an apple, it immediately starts to grow.
- The first apple it eats, it grows by one, the second by two, third by three, and so on.*
- When growing, a snake's tail doesn't extend out as you might expect, instead the tail remains fixed as its head continues to move, stretching it forward.
- You know how when you were a kid and people told you snakes weren't slimy? They lied. In fact, they're super slippery (how do you think they move without legs?).
- Once moving in a given direction, a snake can't stop at all unless it collides with something (a grey wall, a boundary, or another snake - apples don't stop them, and lava... well... see Fact #6).
- Snakes have limited energy to push themselves along.
- They start the day with the energy to initiate movement seven times (once moving they glide smoothly without expending energy, as per Fact #3, above).
- Eating an apple instantly gives them more energy, but with diminishing returns. The first apple gives enough energy to initiate six additional movements, the second gives five, the third four, and so on.*
- Snakes are surprisingly bad at physics, so rather than try to predict where and how fast other snakes are sliding (given they can't stop themselves once they've started), they simply rest whilst another snake in the same territory is moving.
- They're very patient and don't mind waiting for each other, which means it's common to see one snake move many times across the plane, whilst the other takes a break.
- Snakes are allergic to lava. Don't go in the lava.
What set of movements can the two snakes on a plane make in order to eat all the apples?
Hint (15 June):
When is the best time to get the bottom right apple? How are you going to get in there? Having answered those questions, which snake is going to collect it?
Technical Details
*Here's a table providing the exact results of eating each apple (applied independently to each snake):
Apple No. 0 1 2 3 4 5 6
Snake Length 5 6 8 11 15 20 26
Movement Energy 7 +6 +5 +4 +3 +2 +1
Edit (5 June): I've updated the facts above a couple of times to improve clarity, but to boil it down completely without flavour, the rules are as follows:
- Each snake is independent and has its own separate energy/length/movements/apples
- A solution attempt succeeds the instant both snakes have eaten six apples, and fails if either snake runs out of energy or gets trapped without having eaten six apples, or if either touches lava
- Movement
- Only one snake moves at a time, but they don't have to take turns (i.e. one can move many times while the other remains still)
- When a snake starts moving, it continues in a straight line, square by square, whilst the square in front does not contain: a snake, a grey block, or the boundary of the grid
- Snakes can only initiate a limited number of moves, but any given move uses exactly one energy regardless of length
- Each apple provides energy for additional movements (gained the instant they enter the square), as per the table above
- Growth
- When a snake eats an apple it begins growing immediately to the length given in the table above
- Growth occurs incrementally from the head as it moves out the apple's square, with the tail remaining in place until the new length is reached
- Growth can span several movements if the snake is blocked mid-growth
- Multiple growths can compound if an additional apple is eaten before the first growth spurt has completed