Snake game
Your task
Simulate the Snake game on a grid of given width and height. The snake starts length 1 at (row 0, col 0). Food positions are given in order as [row, col] pairs; the snake eats the next food only when its head lands exactly on it. Given a sequence of moves (each 'U','D','L','R'), return the score (food eaten) after the LAST successfully applied move, or -1 as soon as a move kills the snake (running into a wall or its own body). Eating food grows the snake by 1 (tail does not move that step). The snake's body is its own obstacle except that the tail cell vacates as the head advances (unless it just ate).
Examples
snake_game(width: int, height: int, food: list[list[int]], moves: str) -> intExample 1
Input
snake_game(3, 2, [[1, 2], [0, 1]], "RDRUL")Output
2