bjorng
Erlang Core Team
This topic is about Day 2 of the Advent of Code 2021.
We have a private leaderboard (shared with users of Erlang Forums):
https://adventofcode.com/2021/leaderboard/private/view/370884
The entry code is:
370884-a6a71927
Trending in Challenges
Other Trending Topics
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
Hi there! We created Gust: A task orchestrator inspired by Airflow.
For those who have never heard about Aiflow, it’s a Python-based wor...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve.
They are GUI (Emerge) and State management (S...
New
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixirconf-us
- #ai
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming










Showing Posts 1 to 10- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
bjorng
Here is my solution:
https://github.com/bjorng/advent-of-code-2021/blob/1f0f194a4474604341598025821e74c812f8d8fa/day02/lib/day02.ex
APB9785
I used a similar approach
https://github.com/APB9785/AoC-2021-elixir/blob/master/lib/day_02.ex
code-shoily
This one wasn’t as fun as the day 1 one for me.
Aetherus
As usual, my solution is extremely scripting style:
Part 1
Part 2
code-shoily
In Part 1, you could’ve used
but since I was in a noisy room, I made the representation more verbose so I don’t mentally keep track of the which position means what.
Tuple.productand get rid of thatthen? I was contemplating on representing my data structure as tuple only so that I could useTuple.product- one of my favourite functionsClever way to represent the positions though!
stevensonmt
Agree not as fun as Day 1 for some reason. My solution:
https://github.com/stevensonmt/advent_of_code/blob/63ca9e8b1d2c7a1d42ae8840b0fa36fb24391864/2021/day2/day2/lib/day2.ex
Aetherus
Exactly. But the first few days should be a warmup, right?
To make things a little bit more fun, I introduced some sort of sigil.
and then rewrote Part 1:
code-shoily
niiice. I will freeze my Elixir refactor attempts and get an F# solution out tomorrow. There is an opportunity of using a syntax gimmick there which I’d very much like to try out.
You planning on running Benchee for your two solutions?
wasi0013
Here’s mine:
Aetherus
No, but I guess the first solution should be faster since it doesn’t use regular expressions. However, I can make that
sigil_pa macro (the interpolation part can be tricky to implement), and put some of the parsing jobs to the compile-time, but I feel it does not worth the effort because it’s an Elixir script anyway, not a never-should-die service.