123456789101112131415161718192021222324 |
- from util import get_input
- input = get_input("6.input")
- fish = [int(a) for a in input[0].split(",")]
- def run_fish(fish, days):
- fishmap = {i: 0 for i in range(0, 10)}
- for f in fish:
- fishmap[f] += 1
- for _ in range(days):
- new_count = fishmap[0]
- for i in range(0, 8):
- fishmap[i] = fishmap[i + 1]
- fishmap[8] = new_count
- fishmap[6] += new_count
- return sum([v for (k, v) in fishmap.items()])
- print(run_fish(fish, 80))
- print(run_fish(fish, 256))
|