Aetherus
Advent of Code 2023 - Day 8
The second part of today’s puzzle is very misleading.
FYI, each of the ghosts has only one possible position that ends with a "Z" on its path.
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
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
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
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
@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
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
- #elixirconf-us
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #performance
- #security










First 10 of 20 Posts
rugyoga
Aetherus
I did the same thing. Here’s my impl of
lcm/2as an anonymous function:shritesh
I tried letting it run for 5 minutes in part 2 hoping it would work out. It didn’t lol.
Turns out elixir already has gcd in the stdlib: Integer — Elixir v1.20.2. Then the LCM simply becomes
div(x * y, Integer.gcd(x, y))https://github.com/shritesh/advent/blob/main/2023/08.livemd
bjorng
I suspected that was the case, but burned by previous AoC puzzles by making assumptions not explicitly stated in the problem descriptions, I now try to avoid simplifying my code based on assumptions. For this puzzle, I tested all possible end positions for each start positions.
My solution:
https://github.com/bjorng/advent-of-code-2023/blob/main/day08/lib/day08.ex
Aetherus
Good to know. Thanks.
Aetherus
I did my validation of the input, too.
And all the numbers in the return value are a multiple of the length of the L/R instructions.
hauleth
Day 08
Setup
Part 1
Part 2
lud
Ok so I cheated. I had absolutely no idea hwo to tackle part 2 (except letting it run for ever) so I came here and just saw LCM so I went back to check with some code that indeed each ending position cycles.
What I did understand in the problem description is that
LRis equivalent toLRLRLRLR..., but I did not get that the Z position will be found at exactly N repetitions of the moves. So I assumed that, when reaching a Z, you may be left with remaining moves of the moves list, cancelling many possibilities of solving the problem with maths.So, not posting my solution as it will be mostly the same.
midouest
I used Wolfram to solve the LCM, but then went back and implemented it myself: advent-of-code-2023/notebooks/day08.livemd at main · midouest/advent-of-code-2023 · GitHub
celtic9
I was on my way to find an already implemented LCM function on Elixir to solve the second challenge of Day 8 of AoC and Google led me directly to this topic!
I think my solution does not bring anything new to what was already discussed here, but I will share it here anyway
My solutions to the other challenges.