Skip to content

Commit

Permalink
2023: Day 1
Browse files Browse the repository at this point in the history
  • Loading branch information
furgoose committed Dec 1, 2023
1 parent e76cf8c commit 66b72e4
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions aoc_fergus/2023/day01.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
from aocd import lines
import re

total = 0
for line in lines:
m = re.findall(r"\d", line)
total += int(m[0] + m[-1])
print(total)


total2 = 0
for line in lines:
line = (
line.replace("one", "o1e")
.replace("two", "t2o")
.replace("three", "t3e")
.replace("four", "4")
.replace("five", "5e")
.replace("six", "6")
.replace("seven", "7n")
.replace("eight", "e8t")
.replace("nine", "9e")
)
m = re.findall(r"\d", line)
total2 += int(m[0] + m[-1])
print(total2)

0 comments on commit 66b72e4

Please sign in to comment.