Skip to content

Instantly share code, notes, and snippets.

@nns2009
Last active October 9, 2022 11:49
Show Gist options
  • Save nns2009/43227b114eddf732deaffe9b6abd0f4b to your computer and use it in GitHub Desktop.
Save nns2009/43227b114eddf732deaffe9b6abd0f4b to your computer and use it in GitHub Desktop.
I made a game (Bachet/Nim) in under one minute (once again, this is the second one), here it is
# Made in 43 seconds
# Watch this video to see how:
# https://youtu.be/vnYES_fba-M
from random import randint
n = randint(20, 30)
while True:
print(f'{n:2}', '|' * n)
v = int(input('Your turn: '))
if not 1 <= v <= min(3, n):
continue
n -= v
if n == 0:
print('You win')
break
print(f'{n:2}', '|' * n)
v = n % 4 or randint(1, min(3, n))
print('Bot turn:', v)
n -= v
if n == 0:
print('You lose')
break
@Nivesh-GitHub
Copy link

noice

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment