Skip to content

Latest commit

 

History

History
51 lines (38 loc) · 1.06 KB

_292. Nim Game.md

File metadata and controls

51 lines (38 loc) · 1.06 KB

All prompts are owned by LeetCode. To view the prompt, click the title link above.

Back to top


First completed : May 23, 2024

Last updated : July 04, 2024


Related Topics : Math, Brainteaser, Game Theory

Acceptance Rate : 57.27 %


    Notes
    1 - true
    2 - true
    3 - true
    4 - false
    5 - true    -1, any, -3
    6 - true    -2, any, -3
    7 - true    -3, any, -3 
    8 - false 

    As long as you're not a multiple of 4, you can force the other
    into becoming the multiple of 4, thus winning it for yourself.

    Basically just intuitive proof by mathematical induction.

Solutions

Python

class Solution:
    def canWinNim(self, n: int) -> bool:
        return not 0 == n % 4