The Nim Game solutions are below.
15 Jun 2024•Easy•C++ / Python / TypeScript
Nim Game
C++, Python and TypeScript solutions for Nim Game.
Solution files
Python•nim-game/synced-solution.py
def canWinNim(n: int) -> bool:
return n % 4 != 0
C++•nim-game/synced-solution.cpp
class Solution {
public:
bool canWinNim(int n) {
return n % 4 != 0;
}
};
TypeScript•nim-game/synced-solution.ts
function canWinNim(n: number): boolean {
return n % 4 !== 0;
}