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
- #performance
- #security










First 10 of 32 Posts
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
Aetherus
Today I tried LiveBook on the new Elixir 1.13.0, and accidentally deleted my part 1 code, so I just post my part 2:
It feels a little bit tricky implementing a modification-based algorithm in an immutable way.
Aetherus
Sorry for posting twice. There was a network issue when I tried to edit my answer, and I don’t know how to delete one.
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.code-shoily
Here I am thinking the opposite direction, I am thinking
%{value => {row, col}}whererow = div(idx, 5)andcol = rem(idx, 5). That way I can just remove the value into a bucket ofrowlist, collistas I move forward. But it’s feeling slightly weird and verbose.Update: Seems like you’re doing the same thing. Sorry, brain’s not keeping up with eyes lol.
code-shoily
Ah, finally got the first one right, also, I got to use the new
Map.mapUPDATE: Did both parts, Part 2 was quicker to implement, but I don’t have a good feeling about this code for some reason.
princemaple
https://github.com/princemaple/aoc/blob/main/2021/day4.exs
wasi0013
My solution: y2021/day_04.ex
Klohto
I’m already ashamed by posting this horrible Part 1.
At this point, I’ll have to switch to normal function definitions because it’s becoming a spaghetti mess with anons and it’s just Day 4.
Don’t ask how I did Part 2, I have to clean both solutions up first.
It’s a challenge trying to do this in an immutable way.