Ctrl K

Divisor Subtraction Duel

Easy
Two players take turns, and the first player moves first. The number start is written on a board. On a turn, the player picks a divisor d of the current number x with 0 < d < x and x divisible by d, then replaces the number on the board with x - d. A player who cannot move loses. Both play optimally. Return True if the first player wins, and False otherwise.
Example 1
start=4 → True

The first player subtracts 1, leaving 3. The second can only subtract 1, leaving 2. The first subtracts 1 again, leaving 1, and the second has no move.

Example 2
start=1 → False

The number 1 has no suitable divisor, so the first player loses at once.

Example 3
start=5 → False
Constraints
  • 1 ≤ start ≤ 1000
Have you seen this problem in a real interview?
Solved by0
Tried by0
Submissions0
Acceptance—
Topics
Similar problemsTake From Any Pile MediumStone Pile: Who Moves First EasyA Safe Budget for Guessing MediumShared Pool Race to a Goal MediumDuel for the End Cards Medium
loading Python…
Input
start=4
Expected
True

Run checks the first 3 tests in your browser. Submit checks all 53 tests on the server, hidden ones included.