-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path11-1.py
33 lines (27 loc) · 907 Bytes
/
11-1.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
import re
data = '''The first floor contains a hydrogen-compatible microchip and a lithium-compatible microchip.
The second floor contains a hydrogen generator.
The third floor contains a lithium generator.
The fourth floor contains nothing relevant.'''.split('\n')
#data = open('11.txt').read().split('\n')
items = {}
elevator = 1
for i, x in enumerate(data):
m = re.findall(r'a ([\w-]+) (\w+)[,. ]', x)
for g in m:
items[(g[0][0] + g[1][0]).upper()] = i + 1
def draw(items, elevator):
for i in xrange(4, 0, -1):
line = 'F{}'.format(i).ljust(5)
if elevator == i:
line += 'E'.ljust(3)
else:
line += '.'.ljust(3)
for item in items:
if items[item] == i:
line += item.ljust(3)
else:
line += '.'.ljust(3)
print line
print '-'*len(line)
draw(items, elevator)