summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Tom van der Lee <tom@vanderlee.io>2021-12-02 17:39:03 +0100
committerGravatar Tom van der Lee <tom@vanderlee.io>2021-12-02 17:39:03 +0100
commit4dec21f362c03136e9811a4f4c162fcd8c50544e (patch)
treecd90c52c7c936fdbe5fc7f22f3f5bf3240faf9a8
parent37aa8eec0498d7e8491084711132f16db9129a39 (diff)
download2021-4dec21f362c03136e9811a4f4c162fcd8c50544e.tar.gz
2021-4dec21f362c03136e9811a4f4c162fcd8c50544e.tar.bz2
2021-4dec21f362c03136e9811a4f4c162fcd8c50544e.zip
Added day 10
-rw-r--r--Pipfile11
-rw-r--r--Pipfile.lock20
-rw-r--r--aoc/__init__.py3
-rw-r--r--day1/__init__.py28
-rw-r--r--day1/example.txt16
-rw-r--r--day1/input.txt2166
-rw-r--r--day2/__init__.py63
-rw-r--r--day2/example.txt3
-rw-r--r--day2/input.txt1000
-rw-r--r--day3/__init__.py43
-rw-r--r--day3/example.txt11
-rw-r--r--day3/input.txt323
-rw-r--r--day4/__init__.py107
-rw-r--r--day4/example.txt13
-rw-r--r--day4/input.txt1023
-rw-r--r--day5/__init__.py40
-rw-r--r--day5/example.txt3
-rw-r--r--day5/input.txt815
-rw-r--r--day6/__init__.py47
-rw-r--r--day6/example.txt15
-rw-r--r--day6/input.txt2148
-rw-r--r--day7/__init__.py58
-rw-r--r--day7/example.txt9
-rw-r--r--day7/input.txt594
-rw-r--r--day8/__init__.py75
-rw-r--r--day8/example.txt9
-rw-r--r--day8/input.txt624
-rw-r--r--day9/__init__.py63
-rw-r--r--day9/example.txt20
-rw-r--r--day9/input.txt1000
30 files changed, 2005 insertions, 8345 deletions
diff --git a/Pipfile b/Pipfile
deleted file mode 100644
index 5d44a48..0000000
--- a/Pipfile
+++ /dev/null
@@ -1,11 +0,0 @@
1[[source]]
2url = "https://pypi.python.org/simple"
3verify_ssl = true
4name = "pypi"
5
6[packages]
7
8[dev-packages]
9
10[requires]
11python_version = "3.8"
diff --git a/Pipfile.lock b/Pipfile.lock
deleted file mode 100644
index 4cee413..0000000
--- a/Pipfile.lock
+++ /dev/null
@@ -1,20 +0,0 @@
1{
2 "_meta": {
3 "hash": {
4 "sha256": "e2a8a78582d100dc86a0694f5ad982ca341a6b861fd871c6306733562f9e16cc"
5 },
6 "pipfile-spec": 6,
7 "requires": {
8 "python_version": "3.8"
9 },
10 "sources": [
11 {
12 "name": "pypi",
13 "url": "https://pypi.python.org/simple",
14 "verify_ssl": true
15 }
16 ]
17 },
18 "default": {},
19 "develop": {}
20}
diff --git a/aoc/__init__.py b/aoc/__init__.py
index 70c3ac0..07a5fe7 100644
--- a/aoc/__init__.py
+++ b/aoc/__init__.py
@@ -1,7 +1,6 @@
1import os 1import os
2from abc import ABC 2from abc import ABC
3from collections import Iterator 3from typing import Generator, Any, Iterator
4from typing import Generator, Any
5 4
6 5
7class BaseAssignment(ABC): 6class BaseAssignment(ABC):
diff --git a/day1/__init__.py b/day1/__init__.py
index cf48f78..bc44089 100644
--- a/day1/__init__.py
+++ b/day1/__init__.py
@@ -8,29 +8,23 @@ class Assignment(BaseAssignment):
8 return int(item) 8 return int(item)
9 9
10 def read_input(self, example = False) -> List[int]: 10 def read_input(self, example = False) -> List[int]:
11 return sorted(super().read_input(example)) 11 return list(super().read_input(example))
12 12
13class AssignmentOne(Assignment): 13class AssignmentOne(Assignment):
14 def run(self, input: List) -> int: 14 def run(self, input: List) -> int:
15 front_position = 0 15 result = 0
16 end_position = -1
17 16
18 while True: 17 for i in range(1, len(input)):
19 sum = input[front_position] + input[end_position] 18 result += 1 if input[i - 1] < input[i] else 0
20 19
21 if sum > 2020: 20 return result
22 end_position -= 1
23 elif sum < 2020:
24 front_position += 1
25 else:
26 break
27 21
28 return input[front_position] * input[end_position]
29 22
30class AssignmentTwo(Assignment): 23class AssignmentTwo(Assignment):
31 def run(self, input: List) -> int: 24 def run(self, input: List) -> int:
32 for a in input: 25 new_input = [
33 for b in input: 26 input[i - 2] + input[i - 1] + input[i]
34 for c in input: 27 for i in range(2, len(input))
35 if a + b + c == 2020: 28 ]
36 return a * b * c \ No newline at end of file 29
30 return AssignmentOne(path='').run(new_input)
diff --git a/day1/example.txt b/day1/example.txt
index 0bb977d..59dad67 100644
--- a/day1/example.txt
+++ b/day1/example.txt
@@ -1,6 +1,10 @@
11721 1199
2979 2200
3366 3208
4299 4210
5675 5200
61456 \ No newline at end of file 6207
7240
8269
9260
10263 \ No newline at end of file
diff --git a/day1/input.txt b/day1/input.txt
index 0546883..523d802 100644
--- a/day1/input.txt
+++ b/day1/input.txt
@@ -1,200 +1,2000 @@
11511 1171
21344 2173
31925 3174
41970 4163
51864 5161
61951 6157
71557 7156
81984 8154
91743 9152
101526 10156
111972 11151
121945 12153
131969 13132
141760 14135
152008 15151
161592 16143
17736 17141
181963 18149
191994 19145
202009 20147
211777 21142
221856 22143
231899 23139
241926 24141
251850 25144
26147
27137
28144
29147
30153
31151
32153
33157
34185
35186
36185
37181
38161
39177
40179
41177
42178
43173
44175
45183
46181
47191
48189
49186
50189
51192
52191
53189
54199
55208
56218
57216
58210
59209
60208
61215
62207
63198
64202
65204
66205
67204
68203
69205
70207
71208
72209
73218
74234
75231
76245
77244
78243
79265
80264
81279
82282
83283
84274