Showing Posts 1 to 10

Aetherus

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

bjorng

Erlang Core Team

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

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

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

sevenseacat

Author of Ash Framework

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:

Name                     ips        average  deviation         median         99th %
day 09, part 1          9.26      108.03 ms     ±0.66%      107.88 ms      111.50 ms
day 09, part 2          7.28      137.37 ms     ±0.68%      137.22 ms      139.75 ms
Flo0807

Flo0807

Very slow solution today. I might come back optimizing it:

https://github.com/Flo0807/adventofcode/blob/main/2024/09.livemd

jarlah

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:

00...111...2...333.44.5555.6666.777.888899

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

sevenseacat

Author of Ash Framework

No. The example ends with 402 so 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 n2 is zero?

Your 90909 example is also wrong - it should be 000000000111111111222222222. The description says:

A disk map like 90909 would represent three nine-block files in a row (with no free space between them).

jarlah

jarlah

ofc duh! thanks

sevenseacat

sevenseacat

Author of Ash Framework

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.

Where Next? Top

Trending in Challenges Top

Other Trending Topics Top

mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
marciok
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
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Dmk
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
Damirados
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
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews