Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def day24_1():
- import re
- from collections import defaultdict
- with open("input24.txt", "r") as file:
- data = file.readlines()
- floor = defaultdict(lambda: False)
- for line in data:
- coords = re.findall(r"e|se|sw|w|nw|ne", line)
- ns = coords.count("se") + coords.count("sw") - coords.count("ne") - coords.count("nw")
- we = coords.count("e") + coords.count("ne") - coords.count("w") - coords.count("sw")
- floor[(ns, we)] = not floor[(ns, we)]
- return sum([v for v in floor.values()])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement