Game Theory & Minimax
LC #292Easy
Nim Game
Game Theory & Minimax
Problem
You play Nim with your friend. There are n stones. You can remove 1, 2, or 3 stones. Given n, determine if you can win assuming both play optimally.
mathgame-theorybrainteaser
Constraints
- ›1 ≤ n ≤ 2³¹ - 1
Example
Input
n = 4Output
falseWhy
If there are 4 stones, regardless of whether you take 1, 2, or 3, your opponent can easily take the remaining stones to win.