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

Function flow

2018/src/17.py:12–28  ·  view source on GitHub ↗
(m: dict[tuple[int,int],str], ymax: int, x: int, y: int, d: int)

Source from the content-addressed store, hash-verified

10 x += d
11
12def flow(m: dict[tuple[int,int],str], ymax: int, x: int, y: int, d: int) -> bool:
13 if y > ymax:
14 return True
15 if m[x,y] != '.':
16 return m[x,y] == '|'
17
18 m[x,y] = '|'
19 if flow(m,ymax,x,y+1,0):
20 return True
21
22 if (d != 1 and flow(m,ymax,x-1,y,-1)) | (d != -1 and flow(m,ymax,x+1,y,1)):
23 return True
24
25 if d == 0:
26 fill(m,x,y,-1)
27 fill(m,x+1,y,1)
28 return False
29
30@aoc.main('17')
31def main(indata: str) -> tuple[int,int]:

Callers 1

mainFunction · 0.85

Calls 1

fillFunction · 0.85

Tested by

no test coverage detected