Aetherus
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
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
Hi everyone!
The first release candidate for the Expert language server project is now available!
We’ve published a press release detai...
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
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
- #metaprogramming
- #hex
- #security











Showing Posts 1 to 10- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
igorb
Here’s my approach with a
Map: advent-of-code-2024/lib/advent_of_code2024/day5.ex at main · ibarakaiev/advent-of-code-2024 · GitHubruslandoga
Brute
Enum.sort_bywithString.contains?Full: aoc2024/lib/day05.ex at master · ruslandoga/aoc2024 · GitHub
igorb
That’s very clever!
Aetherus
Here is mine:
https://github.com/Aetherus/advent-of-code/blob/60b58f9a2660e8233b8fa3a997adc81517d758f6/2024/day-05.livemd
bjorng
Here is my solution:
https://github.com/bjorng/advent-of-code/blob/main/2024/day05/lib/day05.ex
lud
Insert sort to the rescue
I took the time to check if all possible pairs were defined in the ordering rules, and indeed they are, which makes the puzzle much less hard than what it could have been
Edit : no need for insert sort, this would just work:
code-shoily
I basically sorted each update (int) based on existence in a set (int*int) on (left, right) and (right, left) (used IComparable). And returned a list of tuples where left element is original update and right is sorted (is desired) update
For part 1 - sum of median of left where left = right
For part 2 - sum of median of right where left <> right
Didn’t share the code because not a beam language. It was so much fun (and fast enough) that I decided not to go topo.
lkuty
This is the second time I am bitten by part 2. For day 2 I had to use the solution by @bjorng to find the differences between his output and mine and thus find out where I had made an incorrect assumption since my code looked 100% correct (which it was with the wrong assumption). And now part 2 again. The code looks ok but the answer is wrong
It is working with the sample data
I hope to fix it before day 6.
sevenseacat
It looks like there’s a lot of different approaches today, awesome
https://github.com/sevenseacat/advent_of_code/blob/main/lib/y2024/day05.ex
The first problem this year that I thought was too slow with my naive implementation so I added a
Now part 2 runs in 240ms which I will accept
Task.async_streamto make it fasteredit: Some more optimization and I’m down to 7ms for part 2.
adamu
First, I spent way too long trying to figure out a clever way to generate some kind of tree to represent the order, which I would then process everything through.
But I gave up on that and realised it can be much simpler:
group_bythe pairs to get a map of greater to lesser numbersI also decided to implement two helper anonymous functions
sorted?andgreater?which are closures over the above map.After the above preparation, each part runs in less than a ms.
https://git.adamu.jp/adam/AdventOfCode/src/branch/main/2024/day5.exs