Code Room
CodingMediumcod-g268
Subject Game theoryLevel Mid–Senior~25 minCommon in Algorithms & data structures interviewsIndustries Software development

Question

A pile has n stones. On each turn a player removes between 1 and m stones (inclusive). The player who takes the last stone WINS. Both play optimally and player one moves first. Return True if player one can force a win, else False. 0 <= n <= 10^9, 1 <= m <= 100. With n==0 there are no stones so player one cannot move and loses (return False).

Implement
bachet_first_wins(n: int, m: int) → bool
Examples
in[5,3]outtrue
What a strong answer looks like

State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.

Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.

Run or narrate your approach, then ask the coach.