-
Notifications
You must be signed in to change notification settings - Fork 0
/
read_input.py
51 lines (42 loc) · 1.22 KB
/
read_input.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
from days import days
from block import Block
from colors import colors
def readInput():
blocks = [[], [], [], [], [], []]
important = sys.stdin.readline()
colormap = {}
for line in sys.stdin:
line = line.strip()
parts = line.split(",")
course = parts[0]
if not course in colormap:
colormap[course] = len(colormap) % len(colors)
color = colormap[course]
# TODO gerade / ungerade Wochen unterscheiden
if parts[2] in days:
blocks[days[parts[2]]].append(
Block(
parts[0],
parts[1],
parts[2],
int(parts[3][0]),
parts[4],
color,
parts[0] in important,
)
)
else:
hour = int(parts[3][0]) if len(parts[3]) > 0 else 0
blocks[-1].append(
Block(
parts[0],
parts[1],
"unbekannt",
hour,
parts[4],
color,
parts[0] in important,
)
)
return blocks