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
New episode with Louis Pilfold - the most detailed conversation about Gleam’s design I’ve come across.
Worth knowing for the Elixir comm...
New
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
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)
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.