Trains the technique from
LeetCode 292Nim 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 single stack holds count tiles. You and one opponent take turns, and you take the first turn. On a turn the player whose turn it is removes 1, 2 or 3 tiles from the stack; a player may never pass and may never remove more tiles than the stack holds. Whoever removes the very last tile wins.
Both players see the whole stack and play as well as the position allows. Return true if you can win from this stack no matter how your opponent replies, and false if your opponent can win no matter how you play.
Example 1
You open by taking 3 tiles. Your opponent then takes 1, 2 or 3 of the 4 tiles left, and each of those replies leaves you a stack you clear on your next turn.
Example 2
Whichever of 1, 2 or 3 tiles you open with, your opponent has a reply that keeps you from ever taking the last tile.
Example 3
Taking 3 tiles is legal on a single turn, so you clear the stack immediately and the last tile is yours.
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 can_take_last(count: int) -> bool:public boolean canTakeLast(int count)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.