feat: Initial commit

This commit is contained in:
2024-03-22 17:01:42 +01:00
parent 954985f39a
commit c343ff6e93
106 changed files with 143428 additions and 1 deletions

31
Laboratorio4/nim.py Normal file
View File

@@ -0,0 +1,31 @@
from math import floor, log2
from random import randint
biglie = randint(10, 100)
giocaComputer = randint(0, 1) == 1
intelligente = randint(0, 1) == 1
while biglie > 0:
if giocaComputer:
if intelligente:
if biglie in [3, 7, 15, 31, 63]:
biglie -= randint(1, floor(biglie/2))
else:
biglie -= 3
else:
biglie -= randint(1, floor(biglie/2))
else:
mbiglie = int(input("Quante biglie vuoi togliere? "))
if mbiglie > floor(biglie/2):
print("Non puoi togliere così tante biglie")
continue
biglie -= mbiglie
giocaComputer = not giocaComputer
if giocaComputer:
print("Ha vinto il computer")
else:
print("Ha vinto il giocatore")