Untitled

mail@pastecode.io avatar
unknown
python
2 years ago
612 B
3
Indexable
Never
from collections import Counter
from random import sample
from string import digits

def main():
    random_num = ''.join(sample(digits, 4))
    c = Counter({'bulls': 0, 'cows': 0})

    while c['bulls'] != 4:
        c['bulls'] = c['cows'] = 0
        guess = input() # trust worthy 4 distinct digit number, im not gonna bother checking
         
        for user_digit, random_digit in zip(guess, random_num):
            if user_digit == random_digit: c['bulls'] += 1
            elif user_digit in random_num: c['cows'] += 1

        print(f"{c['bulls']} bulls, {c['cows']} cows")

    print('u win')

main()