Nim is a simple game. Three piles of stones — 3, 5, and 7. Take turns removing 1 or 2 stones from any single pile. Whoever takes the last stone wins.
Simple. But here's the thing that makes Nim special: the game has a perfect mathematical solution. If you know it, you can beat any opponent who doesn't — every single time.
This isn't a strategy article about tips and tricks. This is the actual math that makes Nim solvable. Learn it, and you'll never lose a Nim Duel on SkillClash again (against opponents who don't know it).
Nim starts with three piles:
Pile 1: 3 stones Pile 2: 5 stones Pile 3: 7 stones
Players take turns removing 1 or 2 stones from any single pile. The player who takes the last stone wins.
Your turn. What do you do?
The winning strategy in Nim is based on a mathematical operation called XOR (exclusive OR). It's the same operation used in computer logic — if you've ever programmed, you've seen it as ^.
Here's how it works in binary:
0 XOR 0 = 00 XOR 1 = 11 XOR 0 = 11 XOR 1 = 0The key property: XOR is its own inverse. If you XOR a number with itself, you get zero. This is what makes Nim solvable.
The core of the strategy is a value called nimSum:
nimSum = pile1 XOR pile2 XOR pile3
Compute this at the start of every turn:
nimSum = 0 → you're in a losing position (against perfect play)nimSum ≠ 0 → you're in a winning position — you can force a winPiles: 3, 5, 7. Let's compute nimSum:
3 XOR 5 XOR 7 = ? 3 in binary = 0 1 1 5 in binary = 1 0 1 7 in binary = 1 1 1 ───────────── XOR result = 0 0 1 = 1
nimSum = 1, which is not zero. You're in a winning position.
To win, you need to make a move that leaves nimSum = 0 for your opponent. This forces them into a losing position.
Here's the method:
pile XOR nimSumPiles: 3, 5, 7. nimSum = 1.
3 XOR 1 = 2. Since 2 < 3, this is a valid move. Reduce pile 1 from 3 to 2.5 XOR 1 = 4. Since 4 < 5, this is also valid.7 XOR 1 = 6. Since 6 < 7, this is also valid.All three are winning moves. You could reduce any of them. Let's pick pile 1 → reduce 3 to 2. Now piles are 2, 5, 7.
Check: 2 XOR 5 XOR 7 = 0. ✅ You've left your opponent in a losing position.
Your opponent faces piles 2, 5, 7 with nimSum = 0. Whatever move they make, they'll break the balance — leaving you a nimSum ≠ 0 position, which you can restore to zero on your next turn.
You just have to keep restoring the balance until you take the last stone.
nimSum of all three piles at the start of your turnnimSum = 0, you're in a losing position — play the best move you can and hope for a mistakenimSum ≠ 0, find a pile where reducing it makes nimSum = 0Once you know this strategy, you can beat any opponent who doesn't — 100% of the time from a winning position. Nim isn't a game of intuition. It's a game of arithmetic.
You won't compute binary XOR in your head during a live match. Instead, memorize common positions:
Any position not in the list above is a winning position. Find the move that leads to a losing position for your opponent.
SkillClash starts every Nim Duel with piles of 3, 5, 7. That's a winning position for whoever moves first. So going first is a big advantage.
The winning opening moves are: reduce pile 1 from 3 → 2, or pile 2 from 5 → 4, or pile 3 from 7 → 6. Any of those works.
Pick one, stick with it, and master the follow-ups. Most players won't know the XOR strategy, so you'll win almost every match.
You know the math. Now you need to apply it in real matches. Play 20 games on SkillClash using the XOR method. By match 10, you'll be computing nimSum in your head automatically.
Most opponents won't know this strategy. You'll win far more than you lose.
Play Nim Duel on SkillClash →