maennchen
Advent of Code 2022 - Day 16
Ok, that was a rough one today.
I haven’t found a way to improve the algorithm further. Part 1 runs in .5 seconds, Part 2 in ~ 5 minutes.
https://github.com/maennchen/advent-of-code/blob/main/2022/16/1_depressurize.exs
https://github.com/maennchen/advent-of-code/blob/main/2022/16/2_depressurize_with_elephant.exs
I went the way of precalculating all possible paths between non-zero flow rate valves using :digraph.get_short_path/3. Then I recursively calculate the best step. That works find for 1 actor / 30 iterations. For 2 actors / 26 iterations, that is however still a bit much.
Does anybody have a prettier solution?
Most Liked
kwando
This one was annoying to get right..
Part 1 is more or less instant, part 2 is super duper slow. Would probably work to memoize some computations, but I just let it run embarrassingly long instead, ~30min ![]()
![]()
![]()
lud
I have this solution that runs in 5 or 10 seconds according on how much you want to cheat.
Here I have the correct solution in 5 seconds with keeping the 50_000 best paths but ymmv.
Oh and I did not refactor so it is ugly ![]()
https://github.com/lud/adventofcode/blob/main/lib/solutions/2022/day_16.ex
Popular in Challenges
Other popular topics
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
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance








