6.py 514 B

123456789101112131415161718192021222324
  1. from util import get_input
  2. input = get_input("6.input")
  3. fish = [int(a) for a in input[0].split(",")]
  4. def run_fish(fish, days):
  5. fishmap = {i: 0 for i in range(0, 10)}
  6. for f in fish:
  7. fishmap[f] += 1
  8. for _ in range(days):
  9. new_count = fishmap[0]
  10. for i in range(0, 8):
  11. fishmap[i] = fishmap[i + 1]
  12. fishmap[8] = new_count
  13. fishmap[6] += new_count
  14. return sum([v for (k, v) in fishmap.items()])
  15. print(run_fish(fish, 80))
  16. print(run_fish(fish, 256))