Hello! Advent of Year 2023 is upon us and like past few years, I’ll be opening threads discussing each year’s problems.
Day 1 was today. This was a rather interesting challenge for a day 1. Not as easy as others and the puzzle came with some sneaky edge cases. But regular expressions ftw!
Also this is the first time I am using Scala (or any other language than Elixir) to solve it. While I did not know how to deal with lookahead
on Scala Regex (shame on me), I did quite a nifty trick. Then I went ahead and did Elixir too.
Scala Version
Elixir Version
advent_of_code/lib/2023/day_01.ex at master · code-shoily/advent_of_code (github.com)
There is an interesting difference - Scala one uses two regex patterns (one inverse of the other) while Elixir uses the simpler lookahead regex. I blame my lack of Scala library knowledge here.
See on around Day 2.