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
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
AstonJ
Or which features of current frameworks you use you feel you couldn’t live without?
New
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
finner
During a recent code review I came across this scenario: Code in review if (input.getValue() != null) { return Arrays.asList(value);...
New
New
First poster: bot
About Self Self is a prototype-based dynamic object-oriented programming language, environment, and virtual machine centered around the p...
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
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
dasdom
No chair. I have a standing desk. This post was split into a dedicated thread from our thread about chairs :slight_smile:
New
New
Exadra37
I am a Linux user since 2012, more or less, and I always use Ubuntu on my computers, and my last 2 laptops have been used Thinkpads, wher...
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
PragmaticBookshelf
A Hero’s Journey with Chris Pine @chrispine Chris Pine, author of Learn to Program, Third Edition, discusses his journey to beco...
New
PragmaticBookshelf
Rails 7 completely redefines what it means to produce fantastic user experiences and provides a way to achieve all the benefits of single...
New
PragmaticBookshelf
Author Spotlight Jamis Buck @jamis This month, we have the pleasure of spotlighting author Jamis Buck, who has written Mazes for Prog...
New
AstonJ
If you want a quick and easy way to block any website on your Mac using Little Snitch simply… File > New Rule: And select Deny, O...
New
AstonJ
This is cool! DEEPSEEK-V3 ON M4 MAC: BLAZING FAST INFERENCE ON APPLE SILICON We just witnessed something incredible: the largest open-s...
New