FunctionRacerProblemsRace

Nim Game

EasyMathPython, JavaScript, TypeScript, Java, C++

You and a friend play with a pile of n stones, and you move first. On each turn a player removes 1, 2 or 3 stones. Whoever takes the last stone wins. Both players play perfectly. Return True if you win.

Example 1

n 4
returns false

Whatever you take, your friend takes the rest.

Constraints

Race itor take your time

Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.

More Math problems