Trains the technique from
LeetCode 1025Divisor GameThis is an original problem, written from a brief that listed the technique, the difficulty, the topics, the function shape and the input bounds — none of that problem's wording, examples, hints or editorials. The link is there so you can map your practice onto the standard set.
Same function shape, different story and different numbers.
A counter starts at n. Two players take turns and the first player goes first.
On a turn a player picks a whole number below the counter and above nothing that divides the counter evenly, then lowers the counter by that amount. A player with no legal pick loses.
Both play as well as they can. Return whether the first player wins.
Example 1
Six is even, so the first player lowers it by one and hands over five. Five is odd, so whatever the other player picks leaves an even counter, and the first player keeps handing odd counters back until the other player faces a counter of one.
Example 2
There is no legal pick at all, since a pick has to sit below the counter and above nothing, so the first player loses at once.
Example 3
An odd counter has only odd divisors, so the first player must hand over an even counter and the other player takes the winning side.
The editor is preloaded with this. It matches the parent problem's shape, so a solution that works here transfers to a judge unchanged.
def divisor_game(n: int) -> bool:public boolean divisorGame(int n)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.