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.

Popular Backend topics Top

AstonJ
Partly interested in this so we can set up tags, but also because I’m out of touch with which frameworks are hot right now and I’m curiou...
New
DevotionGeo
For me it’s the semicolon, because I stopped using a semicolon in JavaScript, two other of my favorite languages, Elixir and Go don’t hav...
New
New
finner
Just wondering how many devs out there are using Spring Reactive, specifically WebFlux?
New
AstonJ
Just discovered Fika - looks pretty neat! fn sum(a: Int, b: Int) : Float do a + b end I quite like the syntax, though would probably ...
New
AstonJ
Inspired by this post by @stefan.jarina, I’m curious about the kind of Bash scripts you’ve written and whether you still use Bash given t...
New
finner
I’ve never really felt 100% comfortable using the enum type because of my lack of understanding how it is constructed . . . . . . until ...
New
rustkas
Intensively researching Erlang books and additional resources on it, I have found that the topic of using Regular Expressions is either c...
New
jaeyson
Sorry for the very vague noob question, I really want to ask this: When do we use async or sync code in the context of Elixir? AFAIK gen...
New
luigiluigiluigi
Hey everyone! :wave: We’re looking for a Back-End Developer Volunteer to help us build something impactful! If you want to gain real-wor...
New

Other popular topics Top

malloryerik
Any thoughts on Svelte? Svelte is a radical new approach to building user interfaces. Whereas traditional frameworks like React and Vue...
New
PragmaticBookshelf
A PragProg Hero’s Journey with Brian P. Hogan @bphogan Have you ever worried that your only legacy will be in the form of legacy...
New
New
AstonJ
Inspired by this post from @Carter, which languages, frameworks or other tech or tools do you think is killing it right now? :upside_down...
New
New
New
PragmaticBookshelf
Author Spotlight: Karl Stolley @karlstolley Logic! Rhetoric! Prag! Wow, what a combination. In this spotlight, we sit down with Karl ...
New
PragmaticBookshelf
Author Spotlight: Tammy Coron @Paradox927 Gaming, and writing games in particular, is about passion, vision, experience, and immersio...
New
PragmaticBookshelf
A Ruby-Centric Chat with Noel Rappin @noelrappin Once you start noodling around with Ruby you quickly figure out, as Noel Rappi...
New
AstonJ
If you’re getting errors like this: psql: error: connection to server on socket “/tmp/.s.PGSQL.5432” failed: No such file or directory ...
New