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

Function main

2018/src/17.py:31–42  ·  view source on GitHub ↗
(indata: str)

Source from the content-addressed store, hash-verified

29
30@aoc.main('17')
31def main(indata: str) -> tuple[int,int]:
32 m = defaultdict(lambda: '.')
33 for l in indata.split('\n'):
34 s,a,b = [int(i) for i in re.findall("\d+",l)]
35 hori = l[0] == 'x'
36 for t in range(a,b+1):
37 m[(s,t) if hori else (t,s)] = '#'
38 ymin, ymax = min(y for _,y in m), max(y for _,y in m)
39 flow(m,ymax,500,0,0)
40 water = sum(m[x,y] == '~' for x,y in m if y >= ymin)
41 flows = sum(m[x,y] == '|' for x,y in m if y >= ymin)
42 return water+flows, water
43
44if __name__ == "__main__":
45 main()

Callers 1

17.pyFile · 0.70

Calls 1

flowFunction · 0.85

Tested by

no test coverage detected