summaryrefslogtreecommitdiff
path: root/2016/8b.py
blob: 9c21f259479f5d1950b60edf1132328806a97178 (plain)
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
#!/usr/bin/env python3

import sys

WID=50
HEI=6

screen=[[0]*WID for _ in range(HEI)]

for line in sys.stdin:
	line=line.split(" ")
	if line[0]=="rect":
		w,h=[int(x) for x in line[1].split("x")]
		for y in range(h):
			screen[y][:w]=[1]*w
	elif line[0]=="rotate" and line[1]=="row":
		y=int(line[2][2:])
		off=int(line[4])%WID
		part=screen[y][:-off]
		screen[y][:off]=screen[y][-off:]
		screen[y][off:]=part
	elif line[0]=="rotate" and line[1]=="column":
		x=int(line[2][2:])
		off=int(line[4])%HEI
		part=[row[x] for row in screen[:-off]]
		for y in range(off):
			screen[y][x]=screen[-off+y][x]
		for y in range(len(part)):
			screen[off+y][x]=part[y]

print("\n".join(" ".join(map(lambda n:".#"[n],row)) for row in screen))