-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAoC8.py
26 lines (26 loc) · 913 Bytes
/
AoC8.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
inputdata = open("input.txt")
screen = [['.']*50 for i in range(6)]
for commands in inputdata:
cmd = commands.strip().split(' ')
if cmd[0] == 'rect':
col, row = cmd[1].split('x')
for i in range(0, int(row)):
for j in range(0, int(col)):
screen[i][j] = '#'
elif cmd[0] == 'rotate':
steps = int(cmd[4])
if cmd[1] == 'column':
target = int(cmd[2].lstrip('x='))
for i in range(0,steps):
tmp = screen[5][target]
for j in range(5, 0, -1):
screen[j][target] = screen[j-1][target]
screen[0][target] = tmp
elif cmd[1] == 'row':
target = int(cmd[2].lstrip('y='))
screen[target] = screen[target][-steps:] + screen[target][:-steps]
total = 0
for line in screen:
total += line.count('#')
print(''.join(line))
print(total)