MCPcopy Create free account
hub / github.com/AxlLind/AdventOfCode / part1

Function part1

2018/src/06.py:11–18  ·  view source on GitHub ↗
(points: list[list[int]])

Source from the content-addressed store, hash-verified

9 yield from product(range(xmin,xmax+1), range(ymin,ymax+1))
10
11def part1(points: list[list[int]]) -> int:
12 closest = {}
13 for x,y in bounding_box(points):
14 distances = [abs(a-x) + abs(b-y) for a,b in points]
15 d = min(distances)
16 if distances.count(d) == 1:
17 closest[(x,y)] = distances.index(d)
18 return Counter(closest.values()).most_common(1)[0][1]
19
20def part2(points: list[list[int]]) -> int:
21 ans = 0

Callers 1

mainFunction · 0.70

Calls 2

bounding_boxFunction · 0.85
absFunction · 0.85

Tested by

no test coverage detected