sasajuric
Author of Elixir In Action
Note: This topic is to talk about Day 18 of the Advent of Code.
For general discussion about the Advent of Code 2018 and links to topics of the other days, see this topic.
Trending in Challenges
Other Trending Topics
Edit: 2026 May 15 - This post is archived.
Mob is alive!!
Main docs: mob v0.7.11 — Documentation
A bit of explanation for the slightly c...
New
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
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
Hobbes is a low-level distributed database for the Elixir programming language.
Hobbes provides a simple, safe, and scalable storage lay...
New
Hi everyone!
The first release candidate for the Expert language server project is now available!
We’ve published a press release detai...
New
A little off-topic, but I feel like people here have a good head on their shoulders.
I used to be quite good at making software. Was luc...
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
- #ai
- #ecto-query
- #elixirconf-us
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #elixirconf-eu
- #api
- #forms
- #metaprogramming
- #hex











Showing Posts 1 to 4- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
sasajuric
Here is my take. I solved part 2 by detecting cycles. It’s not super fast, finishes in about 7 sec. There’s some room for optimizing, but I didn’t want to uglify the code
bjorng
I had fun with streams in this one. I also implemented a cycle finding algorithm.
Running the cycle finding algorithm on the infinite stream turned out to be too slow, though, so I cheated a little by pulling out 2000 values to a finite enumerable. That is probably long enough to work for most people’s data sets. The cycle in my data starts at 452 minutes.
It finishes in about 12 minutes.
@sasajuric I liked the elegant way in which you cached the data from the infinite stream and detected the cycle at the same time.
Update: Forgot the link.
JEG2
I caught up just in time to go on vacation: here’s my solution to Day 18:
https://github.com/JEG2/advent_of_code_2018/blob/master/day_18/settlers_of_the_north_pole.exs
marekciupak
My solution: Day 18 - Advent of Code 2018 · GitHub.