igorb
For Part 1, I was lazy and didn’t want to maintain variables and pass them down to each function (which would also involve merging two different histories after each split), so I used the process dictionary trick I learned about in earlier days from @Aetherus to represent state and have the functions produce side effects (which I thought was ugly). For Part 2, though, I was quite happy with this approach because then I just wrapped this code in Task.async_stream/2 and found the max ![]()
https://github.com/ibarakaiev/advent-of-code-2023/blob/main/lib/advent_of_code/day_16.ex
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)
rugyoga
Pretty straightforward.
A MapSet to prevent loops and brute force.
woojiahao
TIL of
~w()ato generate a list of atoms instead of words, pretty cool!https://github.com/woojiahao/aoc/blob/main/lib/aoc/y2023/day_16.ex
bjorng
My solution:
https://github.com/bjorng/advent-of-code-2023/blob/main/day16/lib/day16.ex
Aetherus
Not that interested in today’s puzzles.
Parsing input
Solutions for both parts
lud
Hello,
I was afraid that the second part would ask to rotate mirrors to create the maximum energy but thanks it was much easier.
I have no idea how to optimize that so I just simulate all the beams for part 2, and it takes more than one second. Any idea?
https://github.com/lud/adventofcode/blob/main/lib/solutions/2023/day16.ex
Aetherus
I did the same. It also took me more than 1 second to run, so I just parallelized them
lud
Ah yes I generally do not use task async stream because I like to debug the outputs but now that it works, i’ll try it
Edit: yeah, 500ms, good enough, thanks!
Also
ordered: falsecomes in handywoojiahao
I believe it’s possible to memoize the paths given
(row, column, direction). Since you’re just choosing a different starting position, but if the beam travelingleftreaches\, it should still be the same path throughout. Though, I did not try this out so it could be falsepehbehbeh
Bruteforced part 2 without memoization… takes around 16 seconds in LiveBook on my M2 Pro.
https://github.com/pehbehbeh/adventofcode/blob/main/2023/16.livemd
seoulection
Not sure if this is the right place to post this (and also probably a silly question), but how are y’all parsing the example input? It seems like the escape character is messing up the rows. I’m just doing a simple
String.split(input, "\n"), but the lists/rows are not equal length.