Nim game winning position
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) → boolExamples
in
[5,3]outtrueWhat 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.
0:00 of about 25 min
solution.py
InputExpectedGot
[5,3]truenot run yetsample