mafinar

mafinar

Advent of Code 2023 - Day 1

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

advent-of-scala/src/main/scala/advent_of_scala/2023/Day01.scala at main · code-shoily/advent-of-scala (github.com)

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.

Where Next?

Popular Backend topics Top

AstonJ
Which server-side languages are you most interested in right now? Anything new or relatively new that’s caught your eye? Maybe an older l...
New
New
New
New
New
DevotionGeo
How Dgraph was running out of memory for some users, and how Go’s Garbage collector wasn’t enough, and Dgraph team used jemalloc to manag...
New
AstonJ
In case anyone else is wondering why Ruby 3 doesn’t show when you do asdf list-all ruby :man_facepalming: do this first: asdf plugin-upd...
New
lucasvegi
Hello guys! Perhaps some of you have already seen this invitation on other channels in the Elixir community or even responded to our surv...
New
mafinar
December is only a few weeks away. I have been detached from programming puzzles for a while now so thought I would give myself some warm...
New
mafinar
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....
New

Other popular topics Top

AstonJ
Just done a fresh install of macOS Big Sur and on installing Erlang I am getting: asdf install erlang 23.1.2 Configure failed. checking ...
New
AstonJ
This looks like a stunning keycap set :orange_heart: A LEGENDARY KEYBOARD LIVES ON When you bought an Apple Macintosh computer in the e...
New
AstonJ
In case anyone else is wondering why Ruby 3 doesn’t show when you do asdf list-all ruby :man_facepalming: do this first: asdf plugin-upd...
New
AstonJ
If you are experiencing Rails console using 100% CPU on your dev machine, then updating your development and test gems might fix the issu...
New
PragmaticBookshelf
Build highly interactive applications without ever leaving Elixir, the way the experts do. Let LiveView take care of performance, scalabi...
New
wmnnd
Here’s the story how one of the world’s first production deployments of LiveView came to be - and how trying to improve it almost caused ...
New
AstonJ
We’ve talked about his book briefly here but it is quickly becoming obsolete - so he’s decided to create a series of 7 podcasts, the firs...
New
PragmaticBookshelf
Author Spotlight James Stanier @jstanier James Stanier, author of Effective Remote Work , discusses how to rethink the office as we e...
New
PragmaticBookshelf
Author Spotlight: Sophie DeBenedetto @SophieDeBenedetto The days of the traditional request-response web application are long gone, b...
New
First poster: bot
zig/http.zig at 7cf2cbb33ef34c1d211135f56d30fe23b6cacd42 · ziglang/zig. General-purpose programming language and toolchain for maintaini...
New