rugyoga
Advent of Code 2024 - Day 9
Not the prettiest but it works
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
- #websockets
- #elixirconf-us
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #security
- #hex










First 10 of 30 Posts!
Aetherus
Stuck in Part 2. My algo works for the sample input, but not the real input. Any help?
https://github.com/Aetherus/advent-of-code/blob/0bc39c89cdd8d327fac4aab63b74b828ea2b15f4/2024/day-09.livemd
bjorng
It took me a long time to find an off-by-one error in part 2. The combined runtime for both parts is 0.4 seconds.
https://github.com/bjorng/advent-of-code/blob/main/2024/day09/lib/day09.ex
Aetherus
Finally found the problem. I should not swap a file with a space behind that file.
https://github.com/Aetherus/advent-of-code/blob/178d10a0a3429953ed8fff3df1bca5b3d582e9cb/2024/day-09.livemd
lud
My solution takes 11 seconds adventofcode/lib/solutions/2024/day09.ex at main · lud/adventofcode · GitHub
I have an entry in the disk (a map) for each block. I will see if I can keep all contiguous file parts as a single map entry.
sevenseacat
I am not proud of the code I wrote today.
I totally misunderstood the part 2 problem, came up with some code that gave the right answer anyway somehow but it was too slow, so I rewrote it after actually understanding what I was supposed to do, but it was even slower, so I scratched my head a bit and then rewrote it again.
For such an innocuous-sounding puzzle, that did my head in.
https://github.com/sevenseacat/advent_of_code/blob/main/lib/y2024/day09.ex
Runtime:
Flo0807
Very slow solution today. I might come back optimizing it:
https://github.com/Flo0807/adventofcode/blob/main/2024/09.livemd
jarlah
again just scrolling ultra fast down to not see any spoilers .. is there a bug in day 9 description?
The first example above,
2333133121414131402, represents these individual blocks:but:
left: “00…111…2…333.44.5555.6666.777.8888..99”
right: “00…111…2…333.44.5555.6666.777.888899”
i just made the function by spec …
for extremely simple algo that fails see here https://github.com/jarlah/advent_of_code/blob/master/lib/2024/day_9/Part1.ex#L9
ill eat my hat if it isnt something do with the pattern matching for the parse function … i have even added more tests that prove the more simpler examples is parse correctly
sevenseacat
No. The example ends with
402so there’s 4 eights, 0 gap, and 2 nines.What does your code here https://github.com/jarlah/advent_of_code/blob/master/lib/2024/day_9/Part1.ex#L28 do if
n2is zero?Your 90909 example is also wrong - it should be
000000000111111111222222222. The description says:jarlah
ofc duh! thanks
sevenseacat
There’s been an bug in the problem on only one day that I can remember, in ten years of AOC. And there was a mad uproar about that and it was fixed within an hour.
Last Post!
stevensonmt
Just realized I had set my Github repo to private b/c the AoC dev does not want input files public and I never remember to put it in the gitignore. So almost all my previous day’s solutions are not visible. lol.
Anyway here’s day 9 for me. Not fast enough really but gets the right answer. Could probably get a speed up by updating what the
max_ndxfor searching for files would be in part 2 to avoid searching indices that have already been moved.