Snake Length
Easy · rating 950 · Strings, Simulation
In a snake game the snake starts at length 1. Read a string of moves: F eats food and grows the snake by 1; X means it crashed into itself and the game ends immediately; any other character is an ordinary move. Print the snake's length when the game ends.
Related problems
- Capitalize Words — Easy
- Character Count — Easy
- Count Uppercase Letters — Easy
- Count Words — Easy
- Distinct Words — Easy
- Product of Digits — Easy