igorb
I found today a bit tedious: advent-of-code-2024/lib/advent_of_code2024/day15.ex at main · ibarakaiev/advent-of-code-2024 · GitHub.
Trending in Challenges
Other Trending Topics
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
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
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
With AI doing more of the implementation work, I’ve been wondering how much coding I should deliberately keep doing myself.
My main conc...
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
- #hex
- #security
- #metaprogramming











Showing Posts 1 to 10- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
Aetherus
For part 2, I had a mixed feeling about Elixir. The good part is that immutability and persistent data structures eliminate the need for backtracking. The bad part is that there’s no early return in Elixir, so I had to
throweverywhere. The stupid thing is, I accidentally deleted my code again!igorb
Oh I’d hate to accidentally delete my code for this one… I usually use
reduce_while/3if I need to return early. Tons of it in this problem.bjorng
Another fun puzzle.
https://github.com/bjorng/advent-of-code/blob/main/2024/day15/lib/day15.ex
lud
I thought it was going to be tedious at first but in the end, just a couple modifications from part one are enough. This runs in 15ms:
https://github.com/lud/adventofcode/blob/main/lib/solutions/2024/day15.ex
liamcmitchell
After refactoring in part 2 I ended up with a recursive
movable()function to return a list of movable positions or nil if blocked. I update the map in a second step.https://github.com/liamcmitchell/advent-of-code/blob/e659d35a8a6019bf61c6faac2b514205248f4b21/2024/15/1.exs#L107-L132
Flo0807
I can’t get the solution for part 2. Using the example input, my grid does not look like the one in the puzzle after executing the movements. I even visualized the movements, but can’t figure out where my player does something wrong.
I guess, it is something with pushing the boxes, but I do handle the case where one box pushes two boxes simultaneously
Here are the first 30 seconds visualized (video took longer than 30 seconds, so the full run does not fit in one gif)
This is my grid after all movements:
EDIT: I figured it out now. I did not consider that the player can push boxes that are diagonally placed above / under the player.
I guess, I made part 2 more complicated than it is, but might come back to optimizing it. My source code:
https://github.com/Flo0807/adventofcode/blob/main/2024/15.livemd
adamu
Day
nof failing to quit Advent of Code…This one killed me. Part 2 took me hours. It wasn’t helped by the fact I had a sneaky bug and ended up stepping through the “bigger example” frame by frame to find the edge case. At least the whole thing runs in less than 10ms.
Probably the most interesting thing I did was store the directions as anonymous functions that I then applied to the coordinates.
It actually made debugging more difficult though, because
#Function<13.8856859/1 in Day15.input/0>doesn’t tell you which direction it’s going without running the function…I don’t know what you did but it sounds very different to what I did, which was store the boxes/walls in a map, and assume everything else was free space. Only needed to update any state when the boxes moved.
https://git.adamu.jp/adam/AdventOfCode/src/branch/main/2024/day15.exs
antoine-duchenet
Here is my solution. I’m pretty happy with it, I find it rather neat :
I have been disturbed by this wording :
It made me believe that we had to add mechanics with the right and bottom edges for a while.
adamu
I was worried about that too, but carefully looking at the example showed that it wasn’t necessary. I think the x + 100y requirement is just a simple way to convert a bunch of coordinates to a single number for the purposes of submitting an answer.
I do find it funny how AoC sometimes ties itself in knots explaining a very simple problem like getting an x,y coordinate, while at the same time writing problems where the optimal solution requires prior knowledge such as modulo, quadratic formula, Chinese remainder theorem, graph theory, shortest path algorithm, etc. etc.
jarlah
part 1 was easy .. didnt bother sharing it yesterday .. plus its been awful amount of tile puzzles
but part 2.. thats a fun puzzle .. so in the end after endless refactoring, throwing away, and repeat, i just said eff it .. there is no rule i cant just parse the input and replace all single #, O and . with two of them … then it became awful lot easier to parse the new map .. plus i decided to add ids to the tiles, so i can cross reference it later ..
link: advent_of_code/solutions/2024/day_15/lib/Part2.ex at master · jarlah/advent_of_code · GitHub
now ill maybe go actually solve the problem of gaming programming …