12345678910111213141516171819 |
- import argparse
- from typing import List, Set, NamedTuple
- import functools
- import operator
- parser = argparse.ArgumentParser()
- parser.add_argument("ifile", type=argparse.FileType('r'))
- args = parser.parse_args()
- fish = [int(x) for x in args.ifile.readline().split(',')]
- new_fish_per_day = [0] * (255)
- new_fish_per_day = list(map(sum, zip(*[map(lambda x: int((x % 7) == 0), range(start, -len(new_fish_per_day), -1)) for start in fish])))
- for index, num_new_fish in enumerate(new_fish_per_day):
- for i in range(index + 1 + 8, len(new_fish_per_day), 7):
- new_fish_per_day[i] += num_new_fish
- print(sum(new_fish_per_day) + len(fish))
|