-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
51 lines (41 loc) · 1.45 KB
/
main.py
File metadata and controls
51 lines (41 loc) · 1.45 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
from converters import *
from data import *
import sheet
def generate_draw(names, start_time, both_tees):
random.shuffle(names)
num_teams = int(len(names) / 4)
if len(names) % 4 != 0:
num_teams += 1
if both_tees:
half_field = int(len(names) / 2)
first_tee_draw = generate_draw(names[:half_field], start_time, False)
tenth_tee_draw = generate_draw(names[half_field:], start_time, False)
draw = [first_tee_draw, tenth_tee_draw]
else:
# initializing draw dictionary
draw = initialize_dict(start_time, num_teams)
# assign teams to each time
assign_players(names, draw)
return draw
def assign_players(names, draw):
try:
while len(names) != 0:
for tee_time in draw.keys():
draw[f'{tee_time}'].append(names.pop())
except IndexError as e:
print("Ran out of players")
def initialize_dict(start_time, num_teams):
current_time = time_str_to_int(start_time)
draw = dict()
for team in range(1, num_teams + 1):
draw[f'{current_time}'] = []
if str(current_time + 10).endswith("60"):
current_time +=50
else:
current_time += 10
return draw
if __name__ == "__main__":
print("Starting Now")
dict_to_pdf(generate_draw(sheet.get_names(), "11:00", False))
print("Draw Generation completed")