import sys sys.path.append("../common") import aoc def parse_entry(l): return [int(v) for v in l.split(",")] coordinates = [parse_entry(l) for l in aoc.data.split("\n") if len(l) != 0] def dist(c1, c2): return sum([abs(c1[i] - c2[i]) for i in range(4)]) def get_close(coords, c): match = list() j = 0 while j in range(len(coords)): if dist(c, coords[j]) <= 3: match.append(coords[j]) coords.pop(j) else: j += 1 return match """ sum = 0 for cons in constellations: sum += len(cons) print(sum) """ def solve1(args): constellations = list() available = coordinates[:] while len(available) != 0: match = get_close(available, available[0]) j = 0 while j < len(match): match += get_close(available, match[j]) j += 1 constellations.append(match) return len(constellations) def solve2(args): return "" aoc.run(solve1, solve2, sols=[386, ""])