Isaac Emmanuel
15 Jun 2024•EasyC++ / Python / TypeScript

Nim Game

C++, Python and TypeScript solutions for Nim Game.

The Nim Game solutions are below.

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;
}