|
|
@ -18,22 +18,22 @@ class Reproduce: |
|
|
|
def __init__(self, times: List[int]) -> None: |
|
|
|
self.times = times |
|
|
|
|
|
|
|
def start(self, days: int=80) -> None: |
|
|
|
def start(self, days: int = 80) -> None: |
|
|
|
counts = Counter(self.times) |
|
|
|
for day in range(days): |
|
|
|
next_counts = Counter() # Can't modify while iterating |
|
|
|
next_counts = Counter() # Can't modify while iterating |
|
|
|
|
|
|
|
for count_key, count in counts.items(): |
|
|
|
if count_key == 0: |
|
|
|
next_counts[6] += count # Move the parents back to 6 days |
|
|
|
next_counts[8] += count # Add the new fish |
|
|
|
next_counts[6] += count # Move the parents back to 6 days |
|
|
|
next_counts[8] += count # Add the new fish |
|
|
|
else: |
|
|
|
next_counts[count_key - 1] += count # Move count to next day count |
|
|
|
next_counts[count_key - 1] += count # Move count to next day count |
|
|
|
|
|
|
|
counts = next_counts |
|
|
|
self.time_counts = counts |
|
|
|
|
|
|
|
def count_fish(self): |
|
|
|
def count_fish(self) -> int: |
|
|
|
return sum(self.time_counts.values()) |
|
|
|
|
|
|
|
|
|
|
|