day06
This commit is contained in:
parent
1dc4687c7a
commit
932549ad4c
31
day06.py
Normal file
31
day06.py
Normal file
@ -0,0 +1,31 @@
|
||||
from aoc import AOCDay
|
||||
from typing import Any
|
||||
|
||||
|
||||
def evolve_fishes(start_state: list[int], days: int) -> list[int]:
|
||||
fishes = [0 for i in range(9)]
|
||||
for x in start_state:
|
||||
fishes[x] += 1
|
||||
|
||||
for day in range(days):
|
||||
new_fishes = fishes[0]
|
||||
for x in range(1, 9):
|
||||
fishes[x - 1] = fishes[x]
|
||||
|
||||
fishes[6] += new_fishes
|
||||
fishes[8] = new_fishes
|
||||
|
||||
return fishes
|
||||
|
||||
|
||||
class Day(AOCDay):
|
||||
test_solutions_p1 = [5934]
|
||||
test_solutions_p2 = [26984457539]
|
||||
|
||||
def part1(self) -> Any:
|
||||
start_state = self.getInputAsArraySplit(",", int)
|
||||
return sum(evolve_fishes(start_state, 80))
|
||||
|
||||
def part2(self) -> Any:
|
||||
start_state = self.getInputAsArraySplit(",", int)
|
||||
return sum(evolve_fishes(start_state, 256))
|
||||
1
inputs/input06
Normal file
1
inputs/input06
Normal file
@ -0,0 +1 @@
|
||||
1,5,5,1,5,1,5,3,1,3,2,4,3,4,1,1,3,5,4,4,2,1,2,1,2,1,2,1,5,2,1,5,1,2,2,1,5,5,5,1,1,1,5,1,3,4,5,1,2,2,5,5,3,4,5,4,4,1,4,5,3,4,4,5,2,4,2,2,1,3,4,3,2,3,4,1,4,4,4,5,1,3,4,2,5,4,5,3,1,4,1,1,1,2,4,2,1,5,1,4,5,3,3,4,1,1,4,3,4,1,1,1,5,4,3,5,2,4,1,1,2,3,2,4,4,3,3,5,3,1,4,5,5,4,3,3,5,1,5,3,5,2,5,1,5,5,2,3,3,1,1,2,2,4,3,1,5,1,1,3,1,4,1,2,3,5,5,1,2,3,4,3,4,1,1,5,5,3,3,4,5,1,1,4,1,4,1,3,5,5,1,4,3,1,3,5,5,5,5,5,2,2,1,2,4,1,5,3,3,5,4,5,4,1,5,1,5,1,2,5,4,5,5,3,2,2,2,5,4,4,3,3,1,4,1,2,3,1,5,4,5,3,4,1,1,2,2,1,2,5,1,1,1,5,4,5,2,1,4,4,1,1,3,3,1,3,2,1,5,2,3,4,5,3,5,4,3,1,3,5,5,5,5,2,1,1,4,2,5,1,5,1,3,4,3,5,5,1,4,3
|
||||
1
inputs/test_input06_1_0
Normal file
1
inputs/test_input06_1_0
Normal file
@ -0,0 +1 @@
|
||||
3,4,3,1,2
|
||||
1
inputs/test_input06_2_0
Normal file
1
inputs/test_input06_2_0
Normal file
@ -0,0 +1 @@
|
||||
3,4,3,1,2
|
||||
Loading…
Reference in New Issue
Block a user