Snake game


Create a Snake game (example) that meets the following requirements:

  • 15x15 grid
  • Snake should be controlled with cursor keys (or WASD if you prefer)
  • Snake should start with a length of 3
  • One apple at a time should appear in a random position on the grid. When collected, it should increase the score by one, increase the snake length by one, and change to another random position
  • Display a score for how many apples have been collected
  • If the snake head collides with the rest of the body, the game should end
  • If the snake head collides with the borders, the game should end


Additional challenges

What do you think of this question?

Was this question fair? Too hard? Too easy? Long? Short? We want to hear if this was helpful in your interview prep!