Frans Bergman 3 years ago
parent
commit
68446a4b7d
3 changed files with 26 additions and 0 deletions
  1. 1 0
      6.input
  2. 24 0
      6.py
  3. 1 0
      6.small.input

+ 1 - 0
6.input

@@ -0,0 +1 @@
+4,1,3,2,4,3,1,4,4,1,1,1,5,2,4,4,2,1,2,3,4,1,2,4,3,4,5,1,1,3,1,2,1,4,1,1,3,4,1,2,5,1,4,2,2,1,1,1,3,1,5,3,1,2,1,1,1,1,4,1,1,1,2,2,1,3,1,3,1,3,4,5,1,2,2,1,1,1,4,1,5,1,3,1,3,4,1,3,2,3,4,4,4,3,4,5,1,3,1,3,5,1,1,1,1,1,2,4,1,2,1,1,1,5,1,1,2,1,3,1,4,2,3,4,4,3,1,1,3,5,3,1,1,5,2,4,1,1,3,5,1,4,3,1,1,4,2,1,1,1,1,1,1,3,1,1,1,1,1,4,5,1,2,5,3,1,1,3,1,1,1,1,5,1,2,5,1,1,1,1,1,1,3,5,1,3,2,1,1,1,1,1,1,1,4,5,1,1,3,1,5,1,1,1,1,3,3,1,1,1,4,4,1,1,4,1,2,1,4,4,1,1,3,4,3,5,4,1,1,4,1,3,1,1,5,5,1,2,1,2,1,2,3,1,1,3,1,1,2,1,1,3,4,3,1,1,3,3,5,1,2,1,4,1,1,2,1,3,1,1,1,1,1,1,1,4,5,5,1,1,1,4,1,1,1,2,1,2,1,3,1,3,1,1,1,1,1,1,1,5

+ 24 - 0
6.py

@@ -0,0 +1,24 @@
+from util import get_input
+
+input = get_input("6.input")
+
+fish = [int(a) for a in input[0].split(",")]
+
+
+def run_fish(fish, days):
+    fishmap = {i: 0 for i in range(0, 10)}
+
+    for f in fish:
+        fishmap[f] += 1
+
+    for _ in range(days):
+        new_count = fishmap[0]
+        for i in range(0, 8):
+            fishmap[i] = fishmap[i + 1]
+        fishmap[8] = new_count
+        fishmap[6] += new_count
+    return sum([v for (k, v) in fishmap.items()])
+
+print(run_fish(fish, 80))
+print(run_fish(fish, 256))
+

+ 1 - 0
6.small.input

@@ -0,0 +1 @@
+3,4,3,1,2