summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--day6/__init__.py42
-rw-r--r--day6/example.txt1
-rw-r--r--day6/input.txt1
3 files changed, 44 insertions, 0 deletions
diff --git a/day6/__init__.py b/day6/__init__.py
new file mode 100644
index 0000000..616f055
--- /dev/null
+++ b/day6/__init__.py
@@ -0,0 +1,42 @@
1from collections import Counter
2from copy import copy
3from typing import List
4
5from aoc import BaseAssignment
6
7
8class Assignment(BaseAssignment):
9 days = 80
10
11 def parse_item(self, item: str) -> List[int]:
12 return [ int(i) for i in item.split(',') ]
13
14 def read_input(self, example = False) -> List[int]:
15 return next(super().read_input(example))
16
17 def run(self, input: List[int]) -> int:
18 fish_counter = Counter(input)
19
20 for _ in range(self.days):
21 labour_fish = fish_counter.get(0, 0)
22
23 for fish in range(8):
24 fish_counter[fish] = fish_counter[fish + 1]
25
26 fish_counter[6] += labour_fish
27 fish_counter[8] = labour_fish
28
29 return fish_counter.total()
30
31class AssignmentOne(Assignment):
32 example_result = 5934
33
34class AssignmentTwo(Assignment):
35 example_result = 26984457539
36 days = 256
37
38
39
40
41
42
diff --git a/day6/example.txt b/day6/example.txt
new file mode 100644
index 0000000..a7af2b1
--- /dev/null
+++ b/day6/example.txt
@@ -0,0 +1 @@
3,4,3,1,2 \ No newline at end of file
diff --git a/day6/input.txt b/day6/input.txt
new file mode 100644
index 0000000..b23cbb9
--- /dev/null
+++ b/day6/input.txt
@@ -0,0 +1 @@
5,1,5,3,2,2,3,1,1,4,2,4,1,2,1,4,1,1,5,3,5,1,5,3,1,2,4,4,1,1,3,1,1,3,1,1,5,1,5,4,5,4,5,1,3,2,4,3,5,3,5,4,3,1,4,3,1,1,1,4,5,1,1,1,2,1,2,1,1,4,1,4,1,1,3,3,2,2,4,2,1,1,5,3,1,3,1,1,4,3,3,3,1,5,2,3,1,3,1,5,2,2,1,2,1,1,1,3,4,1,1,1,5,4,1,1,1,4,4,2,1,5,4,3,1,2,5,1,1,1,1,2,1,5,5,1,1,1,1,3,1,4,1,3,1,5,1,1,1,5,5,1,4,5,4,5,4,3,3,1,3,1,1,5,5,5,5,1,2,5,4,1,1,1,2,2,1,3,1,1,2,4,2,2,2,1,1,2,2,1,5,2,1,1,2,1,3,1,3,2,2,4,3,1,2,4,5,2,1,4,5,4,2,1,1,1,5,4,1,1,4,1,4,3,1,2,5,2,4,1,1,5,1,5,4,1,1,4,1,1,5,5,1,5,4,2,5,2,5,4,1,1,4,1,2,4,1,2,2,2,1,1,1,5,5,1,2,5,1,3,4,1,1,1,1,5,3,4,1,1,2,1,1,3,5,5,2,3,5,1,1,1,5,4,3,4,2,2,1,3 \ No newline at end of file