+/AoC

advent of code

git clone https://git.julia.blue/+/AoC

Joseph RyanDay 13f77d550

master
853 B37 linesraw
1points = []
2folds = []
3with open("input") as f:
4    done = False
5    for line in f:
6        temp = line.strip()
7        if not done and temp:
8            a, b = temp.split(",")
9            points.append((int(a), int(b)))
10        else:
11            if not done:
12                done = True
13                continue
14            axis, num = line.split("=")
15            folds.append((axis[-1], int(num)))
16
17
18def fold(pts, fold):
19    axis, pos = fold
20    new = []
21    for p in pts:
22        x, y = p
23        if axis == "y" and y > pos:
24            y = pos - (y - pos)
25        elif axis == "x" and x > pos:
26            x = pos - (x - pos)
27        new.append((x, y))
28    return new
29
30
31print(len(set(fold(points, folds[0]))))
32
33for f in folds:
34    points = fold(points, f)
35
36for y in range(10):
37    print("".join("X" if (x, y) in points else " " for x in range(50)))