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

New
New
First poster: bot
AbstractMachinesLab/caramel. :candy: An Erlang backend to the OCaml compiler. Contribute to AbstractMachinesLab/caramel development by c...
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
CommunityNews
The Magic of Python Context Managers. Recipes for using and creating awesome Python context managers, that will make your code more read...
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
OvermindDL1
Woooooooo! This is such a huge release for it, and 2 years incoming! In short, the library is now using an updated hyper backend (not j...
New
Cellane
I’ve been asked by my supervisors at work to finally give everyone in the team presentation about “that Elixir thing you can’t seem to sh...
New
mafinar
I’ll be participating. This would be very interesting because I have been having coders block + a lot of distraction this weekend. But l...
New
Reinis
I’ve been diving into Bridgetown (a Jekyll successor) and learning about writing a more maintainable CSS.
New

Other popular topics Top

AstonJ
What chair do you have while working… and why? Is there a ‘best’ type of chair or working position for developers?
New
PragmaticBookshelf
Design and develop sophisticated 2D games that are as much fun to make as they are to play. From particle effects and pathfinding to soci...
New
New
New
Exadra37
I am asking for any distro that only has the bare-bones to be able to get a shell in the server and then just install the packages as we ...
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
foxtrottwist
A few weeks ago I started using Warp a terminal written in rust. Though in it’s current state of development there are a few caveats (tab...
New
First poster: bot
The overengineered Solution to my Pigeon Problem. TL;DR: I built a wifi-equipped water gun to shoot the pigeons on my balcony, controlle...
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
CommunityNews
A Brief Review of the Minisforum V3 AMD Tablet. Update: I have created an awesome-minisforum-v3 GitHub repository to list information fo...
New
OSZAR »