aoc

Advent of Code Solutions
git clone git://git.alexkarle.com.com/aoc
Log | Files | Refs | README | LICENSE

a.py (548B) [raw]


      1 #!/usr/bin/env python3
      2 
      3 # XXX: This solution is totally not scalable, and could
      4 # EASILY use the solution to pt B for a faster solution.
      5 # I'm keeping it for posterity to show that I brute forced
      6 # pt A :)
      7 import sys
      8 
      9 fish = []
     10 
     11 def repro(fish):
     12     new = []
     13     for f in fish:
     14         if f == 0:
     15             new += [6, 8]
     16         else:
     17             new.append(f - 1)
     18 
     19     return new
     20 
     21 for l in sys.stdin:
     22     # just keep the last one (only one)
     23     fish = [int(x) for x in l.split(',')]
     24 
     25 for i in range(80):
     26     fish = repro(fish)
     27 
     28 print(len(fish))