Compare commits
No commits in common. "master" and "f1f1636ff7d1b4bfd0be3fc300d704ec6ce29a02" have entirely different histories.
master
...
f1f1636ff7
18
Short_plan
18
Short_plan
|
@ -1,18 +0,0 @@
|
||||||
№1 Короткий план
|
|
||||||
|
|
||||||
1) Задать значения максимального количества попыток и количества символов в одной попытке
|
|
||||||
|
|
||||||
2) Вывод условия игры
|
|
||||||
|
|
||||||
3) Создание случайного числа
|
|
||||||
|
|
||||||
4) Создание основного цикла while для завершения или повторения игры
|
|
||||||
|
|
||||||
5) Создание цикла while для ввода попыток
|
|
||||||
|
|
||||||
6) Создание цикла while для анализа попытки и вывода подсказки
|
|
||||||
|
|
||||||
Идеи:
|
|
||||||
|
|
||||||
1) Добавить уровни сложности, с повышением которых будет
|
|
||||||
увеличиваться длина загаданного слова и уменьшаться количество попыток
|
|
66
main.py
66
main.py
|
@ -1,66 +0,0 @@
|
||||||
import random
|
|
||||||
|
|
||||||
max_nam = 10
|
|
||||||
guess_num = 3
|
|
||||||
|
|
||||||
def create_secret_num(guess_num):
|
|
||||||
digits = list('0123456789')
|
|
||||||
random.shuffle(digits)
|
|
||||||
return ''.join(digits[:guess_num])
|
|
||||||
|
|
||||||
def attempt_check(attemt, secret_num):
|
|
||||||
clue = []
|
|
||||||
for i in range(len(attemt)):
|
|
||||||
|
|
||||||
if attemt[i] == secret_num[i]:
|
|
||||||
clue.append("Fermi")
|
|
||||||
elif attemt[i] in secret_num:
|
|
||||||
clue.append("Pico")
|
|
||||||
sorted(clue)
|
|
||||||
return ' '.join(clue) if clue else 'Bagels'
|
|
||||||
|
|
||||||
def game(max_nam, guess_num):
|
|
||||||
|
|
||||||
print("I meade a number.")
|
|
||||||
attemt_num = 1
|
|
||||||
level = 1
|
|
||||||
while True:
|
|
||||||
if max_nam <= attemt_num:
|
|
||||||
break
|
|
||||||
if level != 1:
|
|
||||||
max_nam += 2
|
|
||||||
guess_num += 1
|
|
||||||
attemt_num = 1
|
|
||||||
secret_num = create_secret_num(guess_num)
|
|
||||||
|
|
||||||
while max_nam >= attemt_num:
|
|
||||||
|
|
||||||
attemt = ''
|
|
||||||
print(f"You have {max_nam} attempt and {guess_num}-digit number")
|
|
||||||
while len(attemt) != guess_num or not attemt.isdecimal():
|
|
||||||
print(f"Attemt {attemt_num}, Level {level}") # Вывод информации о том, сколько попыток сделал игрок
|
|
||||||
attemt = input("> ")
|
|
||||||
|
|
||||||
if secret_num == attemt:
|
|
||||||
print("You win!")
|
|
||||||
print("Next level...")
|
|
||||||
break
|
|
||||||
|
|
||||||
print(attempt_check(attemt,secret_num)) # А вот и подсказка
|
|
||||||
|
|
||||||
attemt_num += 1
|
|
||||||
level += 1
|
|
||||||
print("You're done trying")
|
|
||||||
print(f"The hiden numbers is {secret_num}")
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
|
||||||
while True:
|
|
||||||
game(max_nam, guess_num)
|
|
||||||
if input("You want repeat the game?> ").lower().startswith('n'):
|
|
||||||
print("Thanks for playing")
|
|
||||||
break
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
main()
|
|
|
@ -1,79 +0,0 @@
|
||||||
import random
|
|
||||||
import datetime
|
|
||||||
|
|
||||||
motchs = ('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
|
|
||||||
'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec')
|
|
||||||
|
|
||||||
def getBarthday(inp):
|
|
||||||
date = datetime.date(2000, 1, 1)
|
|
||||||
dates = []
|
|
||||||
for i in range(1, int(inp) + 1):
|
|
||||||
rand_day = datetime.timedelta(random.randint(1, 364))
|
|
||||||
rand_date = date + rand_day
|
|
||||||
dates.append(rand_date)
|
|
||||||
return dates
|
|
||||||
|
|
||||||
def sameDate(dates):
|
|
||||||
if len(dates) == len(set(dates)):
|
|
||||||
return None
|
|
||||||
for a, barthdeyA in enumerate(dates):
|
|
||||||
for b, barthdeyB in enumerate(dates[a + 1:]):
|
|
||||||
if barthdeyA == barthdeyB:
|
|
||||||
return barthdeyA
|
|
||||||
|
|
||||||
def getMonth(dates):
|
|
||||||
for i, date in enumerate(dates):
|
|
||||||
if i != 0:
|
|
||||||
print(', ', end='')
|
|
||||||
motch = motchs[date.month - 1]
|
|
||||||
print(f"{motch} {date.day}", end='')
|
|
||||||
|
|
||||||
def sameMonth(dates):
|
|
||||||
date = sameDate(dates)
|
|
||||||
if date != None:
|
|
||||||
same_date = motchs[date.month - 1]
|
|
||||||
print(f"\nSame a {same_date} {date.day}")
|
|
||||||
else:
|
|
||||||
print("Nohing same")
|
|
||||||
|
|
||||||
def simualtion(inp):
|
|
||||||
digit = 0
|
|
||||||
for i in range(100_000):
|
|
||||||
dates = getBarthday(inp)
|
|
||||||
sam_date = sameDate(dates)
|
|
||||||
if i % 10_000 == 0 and i != 0:
|
|
||||||
print(f"Simulations {i}")
|
|
||||||
if sam_date != None:
|
|
||||||
digit += 1
|
|
||||||
chanse = round((digit/100_000) * 100, 2)
|
|
||||||
print(f"Same = {digit}")
|
|
||||||
print(f"Chanse = {chanse}")
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
|
||||||
while True:
|
|
||||||
inp = ''
|
|
||||||
while not inp.isdecimal() or int(inp) > 100:
|
|
||||||
print("Enter number no more than 100")
|
|
||||||
inp = input("> ")
|
|
||||||
dates = getBarthday(inp)
|
|
||||||
getMonth(dates)
|
|
||||||
sameMonth(dates)
|
|
||||||
simualtion(inp)
|
|
||||||
print("You want play again?")
|
|
||||||
if not input("(yes/no)> ").startswith('y'):
|
|
||||||
print("Thanks for playing")
|
|
||||||
break
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
main()
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue