My Advent of Code solutions in Python. kevinyap.ca/2019/12/going-fast-in-advent-of-code/
advent-of-code python
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Print animated screen to terminal

+15 -3
+15 -3
2016/day08.py
··· 1 + # -*- coding: utf-8 -*- 1 2 import re 3 + import sys 4 + import time 2 5 import fileinput 6 + 3 7 from utils import parse_line 4 8 5 9 WIDTH = 50 6 10 HEIGHT = 6 7 11 SCREEN = [[False for _ in range(WIDTH)] for _ in range(HEIGHT)] 12 + 13 + # Make space for animated output 14 + print '\n' * HEIGHT 8 15 9 16 for line in fileinput.input(): 10 17 if line.startswith('rect'): ··· 27 34 for i, x in enumerate(temp): 28 35 SCREEN[(offset+i) % HEIGHT][n] = x 29 36 30 - print "Number of lit pixels: %i" % sum(sum(row) for row in SCREEN) 31 37 32 - for row in SCREEN: 33 - print ''.join('#' if x else ' ' for x in row) 38 + sys.stdout.write('\033[F' * HEIGHT) 39 + 40 + for row in SCREEN: 41 + print ''.join('█' if x else ' ' for x in row) 42 + 43 + time.sleep(0.02) 44 + 45 + print "\nNumber of lit pixels: %i" % sum(sum(row) for row in SCREEN)