mirror of
https://github.com/thib8956/advent-of-code.git
synced 2025-08-24 08:21:57 +00:00
import more stuff
This commit is contained in:
@@ -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))
|
||||
|
Reference in New Issue
Block a user