PracHub
QuestionsPremiumLearningGuidesInterview PrepNEWCoaches
|Home/Coding & Algorithms/Chime

Simulate toppling board game outcome

Last updated: May 5, 2026

Quick Overview

This question evaluates a candidate's ability to implement a discrete board-game simulation, including state management, turn-based ownership semantics, stack-based piece handling, capture mechanics, and game termination detection.

  • Medium
  • Chime
  • Coding & Algorithms
  • Software Engineer

Simulate toppling board game outcome

Company: Chime

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: Medium

Interview Round: Onsite

Implement a function that, given the board size N (3–9 inclusive) and a list of move strings, returns one of: "in progress", "player 1 is the winner", or "player 2 is the winner". The board is N×N. Players alternate turns and the active player changes on each Place move: all Topple moves between two Place moves belong to the player who executed the preceding Place. Move formats: ( 1) Place: "pXY" places one piece at row X, col Y. You may place only on an empty cell or a cell already owned by the current player. Placing on an empty cell claims it for the current player; otherwise increase the stack height. ( 2) Topple: "tXYD" topples all pieces from (X,Y) in direction D ∈ {u,r,d,l}. You may topple only from a cell you own with stack height ≥2. Pick up all pieces from (X,Y) and drop them one-by-one into adjacent cells starting from the next cell along D; pieces that go off-board are lost. Captures: if a dropped piece lands on a cell owned by the opponent, that piece is captured by the opponent and added to that cell’s stack (ownership of a cell is the owner of the stack on that cell). Game end: as soon as one player has zero pieces anywhere on the board, return the other player as the winner. Assume all moves are valid and well formed. Examples: ["p10", "p12", "p10", "t10r"] → "player 1 is the winner"; ["p00", "p22", "p02", "p22", "t22u", "t02l"] → "player 2 is the winner".

Quick Answer: This question evaluates a candidate's ability to implement a discrete board-game simulation, including state management, turn-based ownership semantics, stack-based piece handling, capture mechanics, and game termination detection.

Related Interview Questions

  • Solve classic backend coding problems - Chime (medium)
  • Implement single-tab browser history navigation - Chime (Medium)
  • Compute minimum time with task cooldowns - Chime (Medium)
  • Find missing number from concatenated digits - Chime (Medium)
Chime logo
Chime
Jul 27, 2025, 12:00 AM
Software Engineer
Onsite
Coding & Algorithms
24
0

Implement a function that, given the board size N (3–9 inclusive) and a list of move strings, returns one of: "in progress", "player 1 is the winner", or "player 2 is the winner". The board is N×N. Players alternate turns and the active player changes on each Place move: all Topple moves between two Place moves belong to the player who executed the preceding Place. Move formats: (

  1. Place: "pXY" places one piece at row X, col Y. You may place only on an empty cell or a cell already owned by the current player. Placing on an empty cell claims it for the current player; otherwise increase the stack height. (
  2. Topple: "tXYD" topples all pieces from (X,Y) in direction D ∈ {u,r,d,l}. You may topple only from a cell you own with stack height ≥2. Pick up all pieces from (X,Y) and drop them one-by-one into adjacent cells starting from the next cell along D; pieces that go off-board are lost. Captures: if a dropped piece lands on a cell owned by the opponent, that piece is captured by the opponent and added to that cell’s stack (ownership of a cell is the owner of the stack on that cell). Game end: as soon as one player has zero pieces anywhere on the board, return the other player as the winner. Assume all moves are valid and well formed. Examples: ["p10", "p12", "p10", "t10r"] → "player 1 is the winner"; ["p00", "p22", "p02", "p22", "t22u", "t02l"] → "player 2 is the winner".

Comments (0)

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Chime•More Software Engineer•Chime Software Engineer•Chime Coding & Algorithms•Software Engineer Coding & Algorithms
PracHub

Master your tech interviews with 7,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.