xAI interview question

Write an algorithm that simulates a game of rockets.