projects/solution-1.py

32 lines
608 B
Python
Executable File

#!/usr/bin/env python3
import random
MAX_GUESSES = 10
def someint():
return random.randint(0, 9)
answer = [ someint(), someint(), someint() ]
attempt = 0
while attempt < MAX_GUESSES:
guess = input(f"Guess #{attempt + 1}: ")
digits = list(map(int, [ guess[0], guess[1], guess[2] ]))
result = [ ]
for idx in range(len(digits)):
if digits[idx] == answer[idx]:
result.append("fermi")
elif digits[idx] in answer:
result.append("pico")
else:
result.append("bagels")
print(" ".join(result))
if digits == answer:
attempt = MAX_GUESSES
else:
attempt += 1