Ctrl K

Shrinking Stone Grabs

Easy
Two players share a pile of stones stones and move in turns, the first player going first. The opening move must take exactly 10 stones. Every later move takes exactly one stone fewer than the opponent's previous move: 10, then 9, then 8, and so on. Whoever cannot take the required number of stones loses. Return True if the first player wins and False otherwise.
Example 1
stones=15 → True

The first player takes 10, leaving 5. The second player must take 9 and cannot, so they lose.

Example 2
stones=19 → False

The first player takes 10, the second takes 9 and the pile is empty. The first player now needs 8 stones and has none, so they lose.

Example 3
stones=7 → False

There are not even enough stones for the very first move.

Constraints
  • 1 ≤ stones ≤ 50
Have you seen this problem in a real interview?
Solved by0
Tried by0
Submissions0
Acceptance—
Topics
Similar problemsSum of Binary Strings EasyFold the Digits Down to One EasyCounting Off by Threes and Fives EasyAdding Long Numbers in Strings EasyGrowing Handouts Around the Circle Easy
loading Python…
Input
stones=15
Expected
True

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