Skip to content

Commit

Permalink
Merge pull request #217 from Stegallo/2023
Browse files Browse the repository at this point in the history
2023
  • Loading branch information
Stegallo authored Dec 8, 2023
2 parents 38289f9 + cc2026f commit 03e6fc0
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 16 deletions.
27 changes: 15 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@

for solutions in rust, refer to [rust repo][rustrepo]

| | 2015 | 2016 | 2017 | 2018 | 2019 | 2020 | 2021 | 2022 |
| | 2015 | 2016 | 2017 | 2018 | 2019 | 2020 | 2021 | 2022 | 2023 |
| - | - | - | - | - | - | - | - | - |
| 01 | [puzzle][201501p]</br>[][201501] | | | | | | | [puzzle][202201p]</br>[][202201] |
| 02 | [puzzle][201502p]</br>[][201502] | | | | | | | |
| 03 | [puzzle][201503p]</br>[][201503] | | | | | | | |
| 04 | [puzzle][201504p]</br>[][201504] | | | | | | | |
| 05 | [puzzle][201505p]</br>[][201505] | | | | | | | |
| 06 | [puzzle][201506p]</br>[][201506] | | | | | | | |
| 07 | [puzzle][201507p]</br>[][201507] | | | | | | | |
| 08 | [puzzle][201508p]</br>[][201508] | | | | | | | |
| 09 | [puzzle][201509p]</br>[][201509] | | | | | | | |
| 10 | [puzzle][201510p]</br>[][201510] | | | | | | | |
| 11 | [puzzle][201511p]</br>[][201511] | | | | | | | |
| 01 | [puzzle][201501p]</br>[][201501] | | | | | | | [puzzle][202201p]</br>[][202201] | [puzzle][202301p]</br>[][202301] |
| 02 | [puzzle][201502p]</br>[][201502] | | | | | | | | |
| 03 | [puzzle][201503p]</br>[][201503] | | | | | | | | |
| 04 | [puzzle][201504p]</br>[][201504] | | | | | | | | |
| 05 | [puzzle][201505p]</br>[][201505] | | | | | | | | |
| 06 | [puzzle][201506p]</br>[][201506] | | | | | | | | |
| 07 | [puzzle][201507p]</br>[][201507] | | | | | | | | |
| 08 | [puzzle][201508p]</br>[][201508] | | | | | | | | |
| 09 | [puzzle][201509p]</br>[][201509] | | | | | | | | |
| 10 | [puzzle][201510p]</br>[][201510] | | | | | | | | |
| 11 | [puzzle][201511p]</br>[][201511] | | | | | | | | |

[201501]: https://github.com/Stegallo/adventofcode/blob/master/y_2015/day1.py
[201501p]: https://adventofcode.com/2015/day/1
Expand Down Expand Up @@ -48,6 +48,9 @@ for solutions in rust, refer to [rust repo][rustrepo]
[202201]: https://github.com/Stegallo/adventofcode/blob/master/y_2022/day1.py
[202201p]: https://adventofcode.com/2022/day/1

[202301]: https://github.com/Stegallo/adventofcode/blob/master/y_2023/day1.py
[202301p]: https://adventofcode.com/2023/day/1

[rustrepo]: https://github.com/Stegallo/adventofcodeinrust

## to run the code
Expand Down
6 changes: 2 additions & 4 deletions y_1900/day0.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,9 @@ def _preprocess_input(self):
self.__input_data = self._input_data[0]

def _calculate_1(self):
x = self.__input_data
print(f"{x=}")
for x in self.__input_data:
print(f"{x}")
return 0

def _calculate_2(self):
x = self.__input_data
print(f"{x=}")
return 0
43 changes: 43 additions & 0 deletions y_2023/day1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
from common.aoc import AoCDay
from typing import List

SPELLED = [
"one",
"two",
"three",
"four",
"five",
"six",
"seven",
"eight",
"nine",
]


class Day(AoCDay):
def __init__(self, test=0):
super().__init__(__name__, test)

def _preprocess_input(self):
self.__input_data = self._input_data[0]

@staticmethod
def replace_word_with_number(input: str) -> str:
for c, k in enumerate(SPELLED):
input = input.replace(k, k + str(c + 1) + k)
return input

@staticmethod
def calculate_calibration(input: List[str]) -> int:
s = 0
for i in input:
j = [x for x in i if x.isnumeric()]
s += int(f"{j[0]}{j[-1]}")
return s

def _calculate_1(self) -> int:
return self.calculate_calibration(self.__input_data)

def _calculate_2(self) -> int:
new_input = [self.replace_word_with_number(i) for i in self.__input_data]
return self.calculate_calibration(new_input)

0 comments on commit 03e6fc0

Please sign in to comment.