-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathschedule.py
More file actions
42 lines (30 loc) · 944 Bytes
/
schedule.py
File metadata and controls
42 lines (30 loc) · 944 Bytes
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
"""
Schedule students for lightning talks, fall 2015
"""
import random
students = open('students.txt').readlines()
# remove the header line
del students[0]
# remove the languages, colon, etc.
students = [line.split(":")[0] for line in students]
# reverse the first, last names
# separate them:
students = [line.split(",") for line in students]
# put them back together
students = ["{} {}".format(first, last) for last, first in students]
# put them in random order
random.shuffle(students)
# make a list from 1 to 10
weeks = list(range(2, 11))
# make three of them...
weeks = weeks * 3
# put the students together with the weeks
schedule = zip(weeks, students)
# sort it for output
schedule = sorted(schedule)
# write it to a file (and print to screen)
with open('schedule.txt', 'w') as outfile:
for week, student in schedule:
line = 'week {}: {}\n'.format(week, student)
print(line)
outfile.write(line)