# queues medium

The Snake

The arcade snake is a deque wearing a costume: eating grows a new head; moving grows a head AND drops the tail. 🐍

You get commands β€” eat:x (new head x) or move:x (new head x, tail vanishes). The snake starts as just start. Print the body head to tail, comma-separated.

Example:

Input: start = "a1", commands = ["eat:a2", "move:a3", "move:a4"] Output: a4,a3

eat:a2 grows a new head without losing the tail (a2, a1). move:a3 adds a new head AND drops the tail (a3, a2). move:a4 does the same (a4, a3).

πŸ’‘ need a hint?

q-the-snake.pyπŸ”’ given lines are locked β€” write your code in between
loading...