Created
July 16, 2020 18:04
-
-
Save pratik7368patil/7d1b1c4ae122ff377234ffad19ace750 to your computer and use it in GitHub Desktop.
Nim Game (Game of Love)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
N1, N2 = [int(v) for v in input().split()][:2] | |
if N1 == N2 or abs(N1-N2) == 1: | |
print("p2") | |
else: | |
print("p1") | |
# More Explaination | |
# ---------------------------------- | |
# 2 2 --- two piles p1 takes a first turn | |
# 0 3 --- p1 can remove any even number of piles from any stack. | |
# 1 1 --- This is p2 last piles remove by p2 | |
# p2 win | |
# In this game we can conclude that no matter how p1 plays p2 will win | |
# You can try with any other stacks. | |
# ----------------------------------- | |
# 2 1 --- let's say we have these two | |
# 0 2 --- move made by p1 | |
# 1 0 --- move made by p2 | |
# p2 win | |
# ----------------------------------- | |
# 2 4 --- let's say we have these two | |
# 3 2 --- Move made by p1 | |
# 1 3 --- Move made by p2 | |
# 2 1 --- Move made by p1 | |
# 0 2 --- Move made by p2 | |
# 1 0 --- Move made by p1 | |
# p1 win |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment