import more stuff

This commit is contained in:
2024-12-03 16:21:15 +01:00
parent d9be62b784
commit 9c9ac3bf3f
4 changed files with 1063 additions and 13 deletions

View File

@@ -1,5 +1,5 @@
#!/usr/bin/env python3
from rules import part1_rules
from rules import part1_rules, part2_rules
def main(grid, rules):
@@ -9,6 +9,8 @@ def main(grid, rules):
generation += 1
grid = next_grid
assert generation < 1000
if generation % 10 == 0:
print(f"Generation {generation}, changes: {changes}")
if changes == 0:
return next_grid.count("#")
@@ -27,6 +29,5 @@ def step(grid, rules):
if __name__ == "__main__":
with open("input.txt") as infile:
grid = list("".join(infile.read().splitlines()))
print("Part 1 ", main(grid, rules=part1_rules))
# print("Part 2 ", main(grid, rules={"L": handle_empty_2, "#": handle_occupied_2}))
print("Part 1 ", main(grid, rules=part1_rules))
print("Part 2 ", main(grid, rules=part2_rules))