Compare commits
16 commits
68bb1132a9
...
a53cf34520
Author | SHA1 | Date | |
---|---|---|---|
Bruno BELANYI | a53cf34520 | ||
Bruno BELANYI | e8d61b3cf8 | ||
Bruno BELANYI | 48e597d188 | ||
Bruno BELANYI | 65943d6c4a | ||
Bruno BELANYI | f42799b6c8 | ||
Bruno BELANYI | f8a4ffa90d | ||
Bruno BELANYI | 5766f226a1 | ||
Bruno BELANYI | 7ba2723a40 | ||
Bruno BELANYI | b7362b4889 | ||
Bruno BELANYI | 78ae52c9c5 | ||
Bruno BELANYI | 571136b6df | ||
Bruno BELANYI | b87458688a | ||
Bruno BELANYI | 57a2d60dc0 | ||
Bruno BELANYI | a968844df2 | ||
Bruno BELANYI | 4195a9e321 | ||
Bruno BELANYI | 9d9dec0715 |
|
@ -1,43 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import itertools
|
||||
import sys
|
||||
from collections import Counter
|
||||
from dataclasses import dataclass
|
||||
from typing import Iterator, List, Tuple
|
||||
|
||||
|
||||
def nth(iterable: Iterator[int], n: int) -> int:
|
||||
return next(itertools.islice(iterable, n, None))
|
||||
|
||||
|
||||
def solve(input: List[str]) -> int:
|
||||
fish = [0] * 9
|
||||
for n, count in Counter(map(int, input[0].split(","))).items():
|
||||
fish[n] = count
|
||||
|
||||
def step(fish: List[int]) -> List[int]:
|
||||
# Count how many clones happen
|
||||
new_fish = fish[0]
|
||||
|
||||
# Do the next cycle
|
||||
fish[0:-1] = fish[1:]
|
||||
fish[6] += new_fish
|
||||
fish[8] = new_fish # Override number of new fish
|
||||
|
||||
return fish
|
||||
|
||||
def iter(fish: List[int]) -> Iterator[List[int]]:
|
||||
while True:
|
||||
yield (fish := step(fish))
|
||||
|
||||
return sum(nth(iter(fish), 80 - 1))
|
||||
|
||||
|
||||
def main() -> None:
|
||||
input = [line.strip() for line in sys.stdin.readlines()]
|
||||
print(solve(input))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
|
@ -1 +0,0 @@
|
|||
3,1,4,2,1,1,1,1,1,1,1,4,1,4,1,2,1,1,2,1,3,4,5,1,1,4,1,3,3,1,1,1,1,3,3,1,3,3,1,5,5,1,1,3,1,1,2,1,1,1,3,1,4,3,2,1,4,3,3,1,1,1,1,5,1,4,1,1,1,4,1,4,4,1,5,1,1,4,5,1,1,2,1,1,1,4,1,2,1,1,1,1,1,1,5,1,3,1,1,4,4,1,1,5,1,2,1,1,1,1,5,1,3,1,1,1,2,2,1,4,1,3,1,4,1,2,1,1,1,1,1,3,2,5,4,4,1,3,2,1,4,1,3,1,1,1,2,1,1,5,1,2,1,1,1,2,1,4,3,1,1,1,4,1,1,1,1,1,2,2,1,1,5,1,1,3,1,2,5,5,1,4,1,1,1,1,1,2,1,1,1,1,4,5,1,1,1,1,1,1,1,1,1,3,4,4,1,1,4,1,3,4,1,5,4,2,5,1,2,1,1,1,1,1,1,4,3,2,1,1,3,2,5,2,5,5,1,3,1,2,1,1,1,1,1,1,1,1,1,3,1,1,1,3,1,4,1,4,2,1,3,4,1,1,1,2,3,1,1,1,4,1,2,5,1,2,1,5,1,1,2,1,2,1,1,1,1,4,3,4,1,5,5,4,1,1,5,2,1,3
|
|
@ -1,43 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import itertools
|
||||
import sys
|
||||
from collections import Counter
|
||||
from dataclasses import dataclass
|
||||
from typing import Iterator, List, Tuple
|
||||
|
||||
|
||||
def nth(iterable: Iterator[int], n: int) -> int:
|
||||
return next(itertools.islice(iterable, n, None))
|
||||
|
||||
|
||||
def solve(input: List[str]) -> int:
|
||||
fish = [0] * 9
|
||||
for n, count in Counter(map(int, input[0].split(","))).items():
|
||||
fish[n] = count
|
||||
|
||||
def step(fish: List[int]) -> List[int]:
|
||||
# Count how many clones happen
|
||||
new_fish = fish[0]
|
||||
|
||||
# Do the next cycle
|
||||
fish[0:-1] = fish[1:]
|
||||
fish[6] += new_fish
|
||||
fish[8] = new_fish # Override number of new fish
|
||||
|
||||
return fish
|
||||
|
||||
def iter(fish: List[int]) -> Iterator[List[int]]:
|
||||
while True:
|
||||
yield (fish := step(fish))
|
||||
|
||||
return sum(nth(iter(fish), 256 - 1))
|
||||
|
||||
|
||||
def main() -> None:
|
||||
input = [line.strip() for line in sys.stdin.readlines()]
|
||||
print(solve(input))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
|
@ -1 +0,0 @@
|
|||
3,1,4,2,1,1,1,1,1,1,1,4,1,4,1,2,1,1,2,1,3,4,5,1,1,4,1,3,3,1,1,1,1,3,3,1,3,3,1,5,5,1,1,3,1,1,2,1,1,1,3,1,4,3,2,1,4,3,3,1,1,1,1,5,1,4,1,1,1,4,1,4,4,1,5,1,1,4,5,1,1,2,1,1,1,4,1,2,1,1,1,1,1,1,5,1,3,1,1,4,4,1,1,5,1,2,1,1,1,1,5,1,3,1,1,1,2,2,1,4,1,3,1,4,1,2,1,1,1,1,1,3,2,5,4,4,1,3,2,1,4,1,3,1,1,1,2,1,1,5,1,2,1,1,1,2,1,4,3,1,1,1,4,1,1,1,1,1,2,2,1,1,5,1,1,3,1,2,5,5,1,4,1,1,1,1,1,2,1,1,1,1,4,5,1,1,1,1,1,1,1,1,1,3,4,4,1,1,4,1,3,4,1,5,4,2,5,1,2,1,1,1,1,1,1,4,3,2,1,1,3,2,5,2,5,5,1,3,1,2,1,1,1,1,1,1,1,1,1,3,1,1,1,3,1,4,1,4,2,1,3,4,1,1,1,2,3,1,1,1,4,1,2,5,1,2,1,5,1,1,2,1,2,1,1,1,1,4,3,4,1,5,5,4,1,1,5,2,1,3
|
Loading…
Reference in a new issue