-
Notifications
You must be signed in to change notification settings - Fork 0
/
MemoryGame.py
35 lines (27 loc) · 892 Bytes
/
MemoryGame.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
from random import sample
from time import sleep
from Utils import clear_console
def generate_sequence(difficulty):
seq_list = sample(range(1, 101), difficulty)
print(seq_list)
sleep(0.7)
clear_console()
return seq_list
def get_list_from_user(difficulty):
user_list = []
print("Please enter " + str(difficulty) + " numbers between 1 to 101")
for i in range(0, difficulty):
user_guess = input("Please enter your " + str(i + 1) + " guess: ")
user_list.append(user_guess)
return user_list
def is_list_equal(gen_list, user_list):
is_equal = True
for num in user_list:
if int(num) not in gen_list:
is_equal = False
break
return is_equal
def play(difficulty):
gen_seq = generate_sequence(difficulty)
user_seq = get_list_from_user(difficulty)
return is_list_equal(gen_seq, user_seq)