sasajuric
Advent of Code - Day 12
Note: This topic is to talk about Day 12 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.
Most Liked
sasajuric
My solution is here.
Part 1 was pretty straightforward. I built a map of rules, and then used a bit of binary pattern matching to move to the next state.
In part 2 it really helped me that I did AoC last year. As soon as I saw it, I knew that there had to be a cycle. I did a quick experiment, and found out that the plants converge to the stable state pretty soon. In that state, the plants relative positioning doesn’t change, but they gradually move in one direction.
I briefly thought about solving this special case, but I wasn’t quite happy with that, because I thought there might exist a more general situation with larger cycles. Therefore, I wrote a more complex recursion which caches pattern transitions, and can handle the cycle of any length.
JEG2
Here’s my solution to Day 12:
https://github.com/JEG2/advent_of_code_2018/blob/master/day_12/subterranean_sustainability.exs
I also found the cycle and quit there.
Here’s a video of the creation of this code (good for 14 days):
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









