summaryrefslogtreecommitdiff
path: root/8b.py
diff options
context:
space:
mode:
authortomsmeding <tom.smeding@gmail.com>2016-12-11 21:18:47 +0100
committertomsmeding <tom.smeding@gmail.com>2016-12-11 21:18:47 +0100
commit97b4c5d86cc12447ac6845e25a863e26a88aec35 (patch)
tree75d65b173b02ce590e9f845addf762ba2c473f78 /8b.py
parent866bfb0aca286da74d2c82cc88ffaf08e6068193 (diff)
7b 8 9a
Diffstat (limited to '8b.py')
-rwxr-xr-x8b.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/8b.py b/8b.py
new file mode 100755
index 0000000..9c21f25
--- /dev/null
+++ b/8b.py
@@ -0,0 +1,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))