Advent of Code solutions

fix day 5

+4 -4
+2 -2
2021/5/p1.py
··· 1 - input = open('input', 'r') 1 + from sys import stdin 2 2 3 3 map = [[0 for _ in range(1000)] for _ in range(1000)] 4 4 5 5 def birange(a, b): return range(a, b + 1) if a < b else range(b, a + 1) 6 6 7 - for line in input: 7 + for line in stdin: 8 8 [[x1, y1], [x2, y2]] = [[int(x) for x in point.strip().split(',')] for point in line.split('->')] 9 9 if x1 == x2: 10 10 for y in birange(y1, y2):
+2 -2
2021/5/p2.py
··· 1 - input = open('input', 'r') 1 + from sys import stdin 2 2 3 3 map = [[0 for _ in range(1000)] for _ in range(1000)] 4 4 ··· 16 16 y1 += sy 17 17 yield [x1, y1] 18 18 19 - for line in input: 19 + for line in stdin: 20 20 [[x1, y1], [x2, y2]] = [[int(x) for x in point.strip().split(',')] for point in line.split('->')] 21 21 for [x, y] in point_range(x1, y1, x2, y2): 22 22 map[x][y] += 1