-
Notifications
You must be signed in to change notification settings - Fork 0
/
day25.py
executable file
·60 lines (40 loc) · 1.21 KB
/
day25.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/usr/bin/env python3
import aoc
def parse_input(input_list):
points = []
for line in input_list:
point = tuple(map(int, line.split(',')))
points.append(point)
return points
def distance(point1, point2):
dist = 0
for one, two in zip(point1, point2):
dist += abs(two - one)
return dist
def part1(input_list):
points = parse_input(input_list)
point_set = set(points)
constellations = []
while point_set:
point = point_set.pop()
constellation = {point}
while constellation:
points_to_add = []
for point in point_set:
for con_point in constellation:
if distance(con_point, point) <= 3:
points_to_add.append(point)
break
for point in points_to_add:
point_set.remove(point)
constellation.add(point)
if not points_to_add:
constellations.append(constellation)
constellation = None
return len(constellations)
def part2(input_list):
if input_list:
pass
return True
if __name__ == "__main__":
aoc.main(part1, part2)