-
Notifications
You must be signed in to change notification settings - Fork 0
/
utils.py
52 lines (40 loc) · 1.03 KB
/
utils.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import sys, os, random
EMAILS = {}
NAMES = []
WICHTEL = {}
def save_name_email(names, emails):
for name, email in zip(names, emails):
EMAILS[name] = email
NAMES.append(name)
def find_wichtel():
found = False
while not found:
found = find_wichtel_helper()
return found
def find_wichtel_helper():
temp = NAMES.copy()
for name in NAMES:
names = temp.copy()
try:
names.remove(name)
except ValueError:
pass
try:
choice = random.choice(names)
except:
return False
temp.remove(choice)
WICHTEL[name] = choice
return _deliver()
def _deliver():
result = []
for name in NAMES:
result.append(_send(name))
return result
def _send(name):
message = 'Hallo '+name+', dein Wichtel ist '+WICHTEL[name]+'.\nLass dir was einfallen!'
return WICHTEL[name], message, EMAILS[name]
if __name__ =='__main__':
save_name_email(['rob','denise','leo','julian'],['test@bla.com','bla@loeffel.de','vegan@gemuese.co.uk','lulatsch@lang.nl'])
print(find_wichtel())
print(WICHTEL)