Aetherus
Advent of Code 2021 - Day 4
This topic is about the Advent of Code 2021 - Day 4.
Thanks to @bjorng , we now have a new Private Leaderboard.
The entry code is:
370884-a6a71927
Trending in Challenges
Other Trending Topics
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
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
Emily is an Elixir library that runs Nx computations on Apple’s MLX. Install it as the default Nx backend and Nx, defn, Axon, Nx.Serving,...
New
I just stumbled on a newly redesigned elixir-lang.org. :tada: It looks like @Software_Mansion did the work, and I think it is generally a...
New
@hugobarauna and I (Alex Koutmos) have been hard at work on writing a book on Nerves that takes you from simply blinking LEDs to building...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #elixirconf-us
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #hex
- #performance










First Post!
bjorng
It is already getting a bit trickier. Here is my solution:
https://github.com/bjorng/advent-of-code-2021/blob/66f5958a3a2fa3043c2b18d5b9b306ce52c742d7/day04/lib/day04.ex
Most Liked
code-shoily
It’s starting to get difficult already, at least from the perspective of Elixir. It’s difficult to come up with a solution fast that is mutation and early return friendly on a matrix like data.
Aetherus
I usually use
%{{x, y} => val}to represent a matrix, but for today’s challenge, I recognized that I need to look up{x, y}by values, so I swapped the keys and the values.hauleth
Again, LiveBook:
Day 4
Input
This time it is a little bit more convoluted, as there are 2 parts of the input.
Fortunately we can easily disect the parts via pattern matching.
Technically the conversion to the numbers is not needed, but it does no harm
and provides additional layer of safety against some whitespace characters left there
and here.
The
Day4.win/2function is manually unrolled, as it is easier to write than somerandom jumping in the list.
Task 1
We simply traverse the
numberslist aggregating the numbers (order doesn’t really matter,here we aggregate them in reverse order to speedup the code). When we have enough numbers
that any of the
bingosis winning one, then we halt the reduction and return computedresult.
Task 2
Whole project can be watched there - https://github.com/hauleth/advent-of-code/blob/master/2021/solutions.livemd
Last Post!
unsek
Jose Valim’s Day 4 stream summary: https://www.youtube.com/watch?v=8_HGMrAZykw