Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- g = open("input").read().splitlines()
- q = [(i, j) for i in range(len(g)) for j in range(len(g[0])) if g[i][j] == 'S']
- dirs = [(0, 1), (-1, 0), (0, -1), (1, 0)]
- for _ in range(64):
- next_q = []
- v = set()
- while q:
- x, y = q.pop()
- for d in dirs:
- x, y = x + d[0], y + d[1]
- if 0 <= x < len(g) and 0 <= y < len(g[0]) and g[x][y] != '#' and (x, y) not in v:
- v.add((x, y))
- next_q.append((x, y))
- q = next_q
- print(f'Part1: {len(v)}')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement