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

DevotionGeo
I know that these benchmarks might not be the exact picture of real-world scenario, but still I expect a Rust web framework performing a ...
New
AstonJ
I’ve seen more and more people get into Rust recently, so thought it would be cool to have a thread for people to share what they like ab...
New
New
DevotionGeo
Some time ago I read somewhere that Rocket will work with stable versions of Rust. The previous version’s changelog says, “Core: Removed...
New
bot
Add sound to your Python game. This is part 13 in an ongoing series about creating video games in Python 3 using the Pygame module. Prev...
New
First poster: bot
The Complete AWS Lambda Handbook for Beginners (Part 1). In the first part of our Complete AWS Lambda Handbook for Beginners, we explain...
New
First poster: bot
https://twitter.com/briandfoy_perl/status/1354535622069919748 This thread was posted by one of our members via one of our news source tr...
New
almokhtar
Howdy, folks i have this question about it is ok to learn two different programming languages same time, well my story is i joined a comp...
New
pillaiindu
Cross posting from Elixir Forum. Build it with Phoenix is a nice course by Geoffrey Lessel @geo. But if you start with Phoenix 1.7.2 or ...
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

Other popular topics Top

AstonJ
SpaceVim seems to be gaining in features and popularity and I just wondered how it compares with SpaceMacs in 2020 - anyone have any thou...
New
brentjanderson
Bought the Moonlander mechanical keyboard. Cherry Brown MX switches. Arms and wrists have been hurting enough that it’s time I did someth...
New
Margaret
Hello content creators! Happy new year. What tech topics do you think will be the focus of 2021? My vote for one topic is ethics in tech...
New
mafinar
Crystal recently reached version 1. I had been following it for awhile but never got to really learn it. Most languages I picked up out o...
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
If you get Can't find emacs in your PATH when trying to install Doom Emacs on your Mac you… just… need to install Emacs first! :lol: bre...
New
First poster: joeb
The File System Access API with Origin Private File System. WebKit supports new API that makes it possible for web apps to create, open,...
New
PragmaticBookshelf
Author Spotlight Mike Riley @mriley This month, we turn the spotlight on Mike Riley, author of Portable Python Projects. Mike’s book ...
New
New
PragmaticBookshelf
Author Spotlight: Peter Ullrich @PJUllrich Data is at the core of every business, but it is useless if nobody can access and analyze ...
New