Advent Of Code
1st December 2023
2023 - Day 1
I'm new to #AdventOfCode, it popped up on my Mastodon timeline and I thought why not take part?
Part one I thought was quite simple. I saved the list as a txt file, opened it and iterated over each line.
The magic was this:
Like others, I had a bit of trouble on part two parsing the
I ended up finding the position of each word-number and seeing which was earliest, then replacing only that instance with the integer.
Then, remove all non-digits and get our first and last digits in the string.
I essentially repeated that but used
strrpos to do the check in reverse to get the last digit.
Looking back, I have a mess of code, but it works. For a bit of fun, that's okay.
I'm looking forward to tomorrow's challenge.
My full responses are found on GitHub