First Post! Switch mode

Aetherus

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 throw everywhere. The stupid thing is, I accidentally deleted my code again!

Most Liked

igorb

igorb

Oh I’d hate to accidentally delete my code for this one… I usually use reduce_while/3 if I need to return early. Tons of it in this problem.

lud

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

Aetherus

Aetherus

For example, in the following case

######
#...##
#[][]#
#.[].#
#.@..#
######

^

In this case, I try to push the box on the 4th row upward, which in requires pushing the left box on the 3rd row upward (ok), then the right box on the 3rd row upward (failed). In traditional programming language, you need to pull back the left box (backtracking), but in Elixir, you just need to use the state before pushing.

Last Post!

Ruthraiah

Ruthraiah

Solution for Part A . Swapping only if value is “O” or “.”

https://github.com/RuthraiahThulasi/advent-of-code/blob/main/day15/AOC_2024-Day15-Part-A.livemd

Where Next?

Trending in Challenges Top

Other Trending Topics Top

JesseHerrick
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
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
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
ausimian
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
type1fool
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
akoutmos
@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

We're in Beta

About us Mission Statement