Level: Senior-Level
Round: Full Journey · Type: Coding · Difficulty: 7/10 · Duration: 60 min · Interviewer: Neutral
Topics: Game Simulation, Arrays, String Manipulation
Location: San Francisco Bay Area
Interview date: 2026-03-01
Question: Implement a function to determine the status of a board game based on a list of moves and the board size.
I need to implement a function that determines the status of a board game based on a list of moves and the size of the board. The function should run through the list of moves and return one of the following game statuses: 'in progress', 'player 1 is the winner', or 'player 2 is the winner'. I am assuming that all moves are valid and well formed.
The board is always a square (e.g., 3x3, 6x6) and is between 3x3 and 9x9 in size.
Each player's turn consists of two types of actions, in this order: Place and Topple.
Place: The player must add a piece to the board once. A piece may only be placed on an open square, or a square with that player’s pieces. If the square is open, a piece is put on that square and that player owns that square. If there are already pieces on the square, another is added.
Topple: Zero or more times, a player takes pieces from a square they own and places them one at a time in a particular direction (left/right/up/down) starting with the next adjacent square. If any of the placed pieces land on an opponent's square, those pieces are captured and become theirs. Pieces that “fall off” the end of the game board are lost.
The game ends when all of one player's pieces are captured.
Input Format I will receive the list of moves as an array of strings, where each string is a move.
Place moves A Place move is denoted by a "p" followed by the coordinates: "p22" would mean a piece was placed at the coordinates 2,2
Topple moves A Topple move is denoted by a "t", the coordinates, and then a direction which is one of "u", "r", "d", "l" corresponding to up, right, down and left: "t00r" would mean the pieces at the coordinates 0,0 topple to the right. If there were say 3 pieces on the square 0,0 these pieces would end up occupying the coordinates 0,1 | 0,2 | 0,3