part2.py 595 B

1234567891011121314151617181920
  1. import argparse
  2. from typing import List, Set, NamedTuple
  3. import functools
  4. parser = argparse.ArgumentParser()
  5. parser.add_argument("ifile", type=argparse.FileType('r'))
  6. args = parser.parse_args()
  7. fish = [int(x) for x in args.ifile.readline().split(',')]
  8. new_fish_per_day = [0] * (256)
  9. for f in fish:
  10. for index in range(f, len(new_fish_per_day), 7):
  11. new_fish_per_day[index] += 1
  12. for index, num_new_fish in enumerate(new_fish_per_day):
  13. for i in range(index + 1 + 8, len(new_fish_per_day), 7):
  14. new_fish_per_day[i] += num_new_fish
  15. print(sum(new_fish_per_day) + len(fish))