Day 05 (minified)

This commit is contained in:
Sebastian Seedorf
2021-12-08 14:25:48 +01:00
parent d5c64799c7
commit e2699eade6
2 changed files with 4 additions and 2 deletions

View File

@@ -9,8 +9,8 @@ points = defaultdict(int)
for line in lines:
[x1, y1, x2, y2] = list(map(int, re.match(r"(\d+),(\d+) -> (\d+),(\d+)", line).groups()))
for x, y in zip(
range(min(x1, x2), max(x1, x2) + 1) if x1 != x2 else repeat(x1),
range(min(y1, y2), max(y1, y2) + 1) if y1 != y2 else repeat(y1)
range(x1, x2+(x1 <= x2)*2-1, (x1 <= x2)*2-1) if x1 != x2 else repeat(x1),
range(y1, y2+(y1 <= y2)*2-1, (y1 <= y2)*2-1) if y1 != y2 else repeat(y1)
):
key = '{},{}'.format(x, y)
points[key] = points[key] + 1