diff options
| -rw-r--r-- | Pipfile | 11 | ||||
| -rw-r--r-- | Pipfile.lock | 20 | ||||
| -rw-r--r-- | aoc/__init__.py | 3 | ||||
| -rw-r--r-- | day1/__init__.py | 28 | ||||
| -rw-r--r-- | day1/example.txt | 16 | ||||
| -rw-r--r-- | day1/input.txt | 2166 | ||||
| -rw-r--r-- | day2/__init__.py | 63 | ||||
| -rw-r--r-- | day2/example.txt | 3 | ||||
| -rw-r--r-- | day2/input.txt | 1000 | ||||
| -rw-r--r-- | day3/__init__.py | 43 | ||||
| -rw-r--r-- | day3/example.txt | 11 | ||||
| -rw-r--r-- | day3/input.txt | 323 | ||||
| -rw-r--r-- | day4/__init__.py | 107 | ||||
| -rw-r--r-- | day4/example.txt | 13 | ||||
| -rw-r--r-- | day4/input.txt | 1023 | ||||
| -rw-r--r-- | day5/__init__.py | 40 | ||||
| -rw-r--r-- | day5/example.txt | 3 | ||||
| -rw-r--r-- | day5/input.txt | 815 | ||||
| -rw-r--r-- | day6/__init__.py | 47 | ||||
| -rw-r--r-- | day6/example.txt | 15 | ||||
| -rw-r--r-- | day6/input.txt | 2148 | ||||
| -rw-r--r-- | day7/__init__.py | 58 | ||||
| -rw-r--r-- | day7/example.txt | 9 | ||||
| -rw-r--r-- | day7/input.txt | 594 | ||||
| -rw-r--r-- | day8/__init__.py | 75 | ||||
| -rw-r--r-- | day8/example.txt | 9 | ||||
| -rw-r--r-- | day8/input.txt | 624 | ||||
| -rw-r--r-- | day9/__init__.py | 63 | ||||
| -rw-r--r-- | day9/example.txt | 20 | ||||
| -rw-r--r-- | day9/input.txt | 1000 |
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]] | ||
| 2 | url = "https://pypi.python.org/simple" | ||
| 3 | verify_ssl = true | ||
| 4 | name = "pypi" | ||
| 5 | |||
| 6 | [packages] | ||
| 7 | |||
| 8 | [dev-packages] | ||
| 9 | |||
| 10 | [requires] | ||
| 11 | python_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 @@ | |||
| 1 | import os | 1 | import os |
| 2 | from abc import ABC | 2 | from abc import ABC |
| 3 | from collections import Iterator | 3 | from typing import Generator, Any, Iterator |
| 4 | from typing import Generator, Any | ||
| 5 | 4 | ||
| 6 | 5 | ||
| 7 | class BaseAssignment(ABC): | 6 | class 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 | ||
| 13 | class AssignmentOne(Assignment): | 13 | class 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 | ||
| 30 | class AssignmentTwo(Assignment): | 23 | class 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 @@ | |||
| 1 | 1721 | 1 | 199 |
| 2 | 979 | 2 | 200 |
| 3 | 366 | 3 | 208 |
| 4 | 299 | 4 | 210 |
| 5 | 675 | 5 | 200 |
| 6 | 1456 \ No newline at end of file | 6 | 207 |
| 7 | 240 | ||
| 8 | 269 | ||
| 9 | 260 | ||
| 10 | 263 \ 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 @@ | |||
| 1 | 1511 | 1 | 171 |
| 2 | 1344 | 2 | 173 |
| 3 | 1925 | 3 | 174 |
| 4 | 1970 | 4 | 163 |
| 5 | 1864 | 5 | 161 |
| 6 | 1951 | 6 | 157 |
| 7 | 1557 | 7 | 156 |
| 8 | 1984 | 8 | 154 |
| 9 | 1743 | 9 | 152 |
| 10 | 1526 | 10 | 156 |
| 11 | 1972 | 11 | 151 |
| 12 | 1945 | 12 | 153 |
| 13 | 1969 | 13 | 132 |
| 14 | 1760 | 14 | 135 |
| 15 | 2008 | 15 | 151 |
| 16 | 1592 | 16 | 143 |
| 17 | 736 | 17 | 141 |
| 18 | 1963 | 18 | 149 |
| 19 | 1994 | 19 | 145 |
| 20 | 2009 | 20 | 147 |
| 21 | 1777 | 21 | 142 |
| 22 | 1856 | 22 | 143 |
| 23 | 1899 | 23 | 139 |
| 24 | 1926 | 24 | 141 |
| 25 | 1850 | 25 | 144 |
| 26 | 147 | ||
| 27 | 137 | ||
| 28 | 144 | ||
| 29 | 147 | ||
| 30 | 153 | ||
| 31 | 151 | ||
| 32 | 153 | ||
| 33 | 157 | ||
| 34 | 185 | ||
| 35 | 186 | ||
| 36 | 185 | ||
| 37 | 181 | ||
| 38 | 161 | ||
| 39 | 177 | ||
| 40 | 179 | ||
| 41 | 177 | ||
| 42 | 178 | ||
| 43 | 173 | ||
| 44 | 175 | ||
| 45 | 183 | ||
| 46 | 181 | ||
| 47 | 191 | ||
| 48 | 189 | ||
| 49 | 186 | ||
| 50 | 189 | ||
| 51 | 192 | ||
| 52 | 191 | ||
| 53 | 189 | ||
| 54 | 199 | ||
| 55 | 208 | ||
| 56 | 218 | ||
| 57 | 216 | ||
| 58 | 210 | ||
| 59 | 209 | ||
| 60 | 208 | ||
| 61 | 215 | ||
| 62 | 207 | ||
| 63 | 198 | ||
| 64 | 202 | ||
| 65 | 204 | ||
| 66 | 205 | ||
| 67 | 204 | ||
| 68 | 203 | ||
| 69 | 205 | ||
| 70 | 207 | ||
| 71 | 208 | ||
| 72 | 209 | ||
| 73 | 218 | ||
| 74 | 234 | ||
| 75 | 231 | ||
| 76 | 245 | ||
| 77 | 244 | ||
| 78 | 243 | ||
| 79 | 265 | ||
| 80 | 264 | ||
| 81 | 279 | ||
| 82 | 282 | ||
| 83 | 283 | ||
| 84 | 274 | ||
