Add day 1-5

This commit is contained in:
2024-12-18 23:45:11 -07:00
commit ebd8d45970
61 changed files with 932 additions and 0 deletions
View File
View File
+61
View File
@@ -0,0 +1,61 @@
#!/usr/bin/env python3
filename = "example.txt"
filename = "input.txt"
with open(filename) as f:
input = f.read().strip()
accumulator = 0
x = 0
i = 0
while True:
print("\n\n")
a = input[i:].find("mul(")
a_mod = a + i
b = input[a_mod:].find(",")
b_mod = b + a_mod
c = input[a_mod:].find(")")
c_mod = c + a_mod
if a == -1:
break
if b == -1:
break
if c == -1:
break
a = a_mod
b = b_mod
c = c_mod
print(input[i:])
print(input[a:])
print(input[b:])
print(input[c:])
print(a, b, c)
print(input[a+4:b])
print(input[b+1:c])
try:
val0 = int(input[a+4:b])
val1 = int(input[b+1:c])
except ValueError:
i = a + 4
#if x == 2:
# break
#x += 1
continue
print(f"{val0=}")
print(f"{val1=}")
accumulator += val0 * val1
i = c + 1
print(accumulator)
+1
View File
@@ -0,0 +1 @@
xmul(2,4)%&mul[3,7]!@^do_not_mul(5,5)+mul(32,64]then(mul(11,8)mul(8,5))
+14
View File
@@ -0,0 +1,14 @@
[tool.poetry]
name = "aoc"
version = "0.1.0"
description = ""
authors = ["restitux <restitux@ohea.xyz>"]
readme = "README.md"
[tool.poetry.dependencies]
python = "^3.12"
[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
View File