2023(1): Treat written digits as digits

This is wrong, though, as cases like `oneight` should return `83` whereas
I replace the `one`s first, so that `1ight` will remain that way.

See <https://www.reddit.com/r/adventofcode/comments/1884fpl/2023_day_1for_those_who_stuck_on_part_2/>.
This commit is contained in:
2023-12-02 22:03:52 +01:00
parent ce39b976ab
commit 1c17fcede7
2 changed files with 51 additions and 2 deletions

View File

@ -27,3 +27,28 @@ In this example, the calibration values of these four lines are `12`, `38`, `15`
Consider your entire calibration document. _What is the sum of all of the calibration values?_
To begin, [get your puzzle input](https://adventofcode.com/2023/day/1/input).
Your puzzle answer was `54990`.
The first half of this puzzle is complete! It provides one gold star: *
## --- Part Two ---
Your calculation isn't quite right. It looks like some of the digits are actually _spelled out with letters_: `one`, `two`, `three`, `four`, `five`, `six`, `seven`, `eight`, and `nine` _also_ count as valid "digits".
Equipped with this new information, you now need to find the real first and last digit on each line. For example:
```
two1nine
eightwothree
abcone2threexyz
xtwone3four
4nineeightseven2
zoneight234
7pqrstsixteen
```
In this example, the calibration values are `29`, `83`, `13`, `24`, `42`, `14`, and `76`. Adding these together produces `_281_`.
_What is the sum of all of the calibration values?_