-
Notifications
You must be signed in to change notification settings - Fork 11
/
kattis_musicalnotation.py
50 lines (45 loc) · 988 Bytes
/
kattis_musicalnotation.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
'''
Kattis - musicalnotation
Note that tedious. Just follow the question.
Time: O(n), Space: O(n)
'''
ans = {
"G": "G: ",
"F": "F: ",
"E": "E: ",
"D": "D: ",
"C": "C: ",
"B": "B: ",
"A": "A: ",
"g": "g: ",
"f": "f: ",
"e": "e: ",
"d": "d: ",
"c": "c: ",
"b": "b: ",
"a": "a: ",
}
auto_line = {"F", "D", "B", "g", "e", "a"}
n = int(input())
notes = input().split()
for note in notes:
if len(note) == 1:
letter = note[0]
length = 1
else:
letter, length = note[0], note[1]
length = int(length)
for l in ans:
if letter == l:
ans[l] += "*" * length
else:
ans[l] += ("-" if l in auto_line else " ") * length
letter = "_ "
length = 1
for l in ans:
if letter == l:
ans[l] += "*" * length
else:
ans[l] += ("-" if l in auto_line else " ") * length
for l in ans:
print(ans[l][:-1])