From 2c1dccf57d7ad5e25e79063dea41fd7bfa9d9ac6 Mon Sep 17 00:00:00 2001 From: tomsmeding Date: Sat, 2 Dec 2017 09:30:07 +0100 Subject: Move 2016 to its own folder --- 2016/8b.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100755 2016/8b.py (limited to '2016/8b.py') diff --git a/2016/8b.py b/2016/8b.py new file mode 100755 index 0000000..9c21f25 --- /dev/null +++ b/2016/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)) -- cgit v1.2.3-70-g09d2