Search⌘ K
AI Features

Solution: Nim Game

Solution: Nim Game asks whether you can win a one-heap stone game when both players play optimally, removing one to three stones per turn and taking the last stone. Return TRUE or FALSE.

Statement

You and a friend are playing a game called the Nim Game with a heap of stones. The rules are as follows:

  • There is a single heap containing n stones.

  • You and your friend take alternating turns, with you going first.

  • On each turn, the current player must remove between ...