Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def day11(s, *, part2=False):
- growth = 1_000_000 if part2 else 2
- grid = np.array([list(line) for line in s.splitlines()])
- galaxies = np.argwhere(grid == '#')
- occupied = [{galaxy[c] for galaxy in galaxies} for c in range(2)]
- total = 0
- for galaxy1, galaxy2 in itertools.combinations(galaxies, 2):
- for a, b, occ in zip(galaxy1, galaxy2, occupied):
- total += sum(1 if x in occ else growth for x in range(min(a, b), max(a, b)))
- return total
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement