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
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
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
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
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
- #blog-post
- #phoenix_html
- #iex
- #graphql
- #ai
- #genstage
- #elixirconf-us
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #security
- #hex










Showing Posts 1 to 10- Show Best Posts
- Show All Posts (oldest first)
- Show All Posts (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