-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrelaxed_bingo.py
More file actions
51 lines (42 loc) · 1.46 KB
/
relaxed_bingo.py
File metadata and controls
51 lines (42 loc) · 1.46 KB
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import random
def create_bingo_card():
"This function creates a random BINGO card for a player."
card = {"B": [], "I": [], "N": [], "G": [], "O": []}
max_range = 15
low_range = 1
for key in card:
while len(card[key]) < 5:
integer = random.randint(low_range, max_range)
if len(card[key]) == 2 and key == "N":
card[key].append("FREE")
elif integer not in card[key]:
card[key].append(integer)
low_range = max_range + 1
max_range += 15
return card
def check_horizontals(card): # Check only for horizontal win conditions
"Starts at the top row and checks from there."
for i in range(5):
total = 0
for key in card:
if type(card[key][i]) == int:
total += card[key][i]
else:
total += 0
if total == 0:
return True
return False
def check_verticals(card): # Check only for vertical win conditions
"Starts at the left and moves right."
card['N'][2] = 0
for key in card:
if sum(card[key]) == 0:
return True
return False
def check_card(card):
if check_horizontals(card):
return ("You've won on the horizontals!")
elif check_verticals(card):
return ("You've won on the verticals!")
else:
return ("This was not a winning card, better luck next time!")