Module aoc::y23d01

source ·
Expand description

Advent of Code 2023 Day 1: https://adventofcode.com/2023/day/1

A rather challenging problem for day one! Part one was very straightforward but it took me a while to figure out how to solve part two. My initial implementation used a regex to try and account for both numbers and the number-words but there were many edge cases and after a few wrong submission attempts I gave up and got the trick from the subreddit. The trick is rather simple: just replace the number words with the number wrapped by its number word (e.g., “one” becomes “one1one”). This lets us also account for multiple numbers encoded into a single word (see example below in the function description).

Functions§

  • The solution the day one challenge.