Function
flow
(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 | |
| 12 | def 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') |
| 31 | def main(indata: str) -> tuple[int,int]: |
Tested by
no test coverage detected