This commit is contained in:
2025-12-01 16:31:40 -05:00
commit 0dfbea1175
8 changed files with 4133 additions and 0 deletions

10
.gitignore vendored Normal file
View File

@@ -0,0 +1,10 @@
# Python-generated files
__pycache__/
*.py[oc]
build/
dist/
wheels/
*.egg-info
# Virtual environments
.venv

1
.python-version Normal file
View File

@@ -0,0 +1 @@
3.14

0
README.md Normal file
View File

10
day-1-test.txt Normal file
View File

@@ -0,0 +1,10 @@
L68
L30
R48
L5
R60
L55
L1
L99
R14
L82

57
day-1.py Normal file
View File

@@ -0,0 +1,57 @@
class SafeBreaker:
def __init__(self):
self.value = 50
self.times_pointing_zero = 0
def move_dial(self, instruction: str) -> None:
direction = instruction[0]
multiplier = -1 if direction == "L" else 1
movement = int(instruction[1:])
self.times_pointing_zero += int(movement / 100)
movement_value = multiplier * (movement % 100)
# Move
original_value = self.value
self.value = self.value + movement_value
if self.value < 0:
if original_value != 0:
self.times_pointing_zero += 1
print("past 0")
self.value = 100 + self.value
elif self.value >= 100:
print("past 0")
self.times_pointing_zero += 1
self.value = self.value % 100
elif self.value == 0:
self.times_pointing_zero += 1
def get_password(self) -> int:
return self.times_pointing_zero
def crack_safe(self, instructions: list[str]) -> int:
for instruction in instructions:
self.move_dial(instruction)
print(instruction, self.value)
return self.get_password()
if __name__ == "__main__":
instructions = []
with open("./day-1.txt", "r") as file:
for line in file.readlines():
instructions.append(line.strip())
sb = SafeBreaker()
password = sb.crack_safe(instructions)
print(password)

4042
day-1.txt Normal file

File diff suppressed because it is too large Load Diff

6
main.py Normal file
View File

@@ -0,0 +1,6 @@
def main():
print("Hello from aoc-2025!")
if __name__ == "__main__":
main()

7
pyproject.toml Normal file
View File

@@ -0,0 +1,7 @@
[project]
name = "aoc-2025"
version = "0.1.0"
description = "Add your description here"
readme = "README.md"
requires-python = ">=3.14"
dependencies = []