bjorng
Erlang Core Team
This topic is about Day 17 of the Advent of Code 2020 .
Thanks to @egze, we have a private leaderboard:
https://adventofcode.com/2020/leaderboard/private/view/39276
The join code is:
39276-eeb74f9a
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
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
Hi everyone!
The first release candidate for the Expert language server project is now available!
We’ve published a press release detai...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
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
- #ai
- #elixirconf-us
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #elixirconf-eu
- #metaprogramming
- #hex










Showing Posts 1 to 10- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
bjorng
Interesting twist in part 2. I had expected the number of cycles to be hugely increased.
I did not try to make a general solution that would share most code between part 1 and part 2. Instead, I copied the my part 1 solution and added another dimension. No further optimizations were needed since both parts run in about 3.2 seconds on my computer.
Here is my solution.
mruoss
Is there a mistake in the initial state of the example or am I not getting it? E.g. why does -1, 1, -1 (top left corner in z=-1) get active after 1 cycle? The only active neighbour in the initial state was 0, 1, 0 (top middle), no?
Hallski
They updated the text slightly after a while since a lot of people got confused by the example (me included). In short, the top left coordinate in the z0 layer is not the same in each iteration and moves around depending on where there are active satellites.
Hallski
Struggled for about an hour trying to make sense of the examples (and thought they meant the space wrapped around which created a real headache with a growing universe
).
I settled for storing the active satellites in a map, keyed on coordinates. Then I ran each iteration and checked all positions within my active state plus one in each direction.
Here is my solution.
Part 2 was simply extending part 1 with an extra dimension so only posted that.
@bjorng nice to use
Stream.iterate() |> Enum.drop(6), also realised reading your code that I was a bit silly to filter my Map and useEnum.countsince I also only store the active satellites in my map.lud
Finally ! Finally My huge copy and paste skills could be used at their full potential for part 2.
My solution finishes under 2 seconds for part 2 so I am satisfied with it. For each iteration I generate a list of changes that I apply to the map all at once at the end of each turn. Remembering day 11, this technique does not improve performance drastically compared to directly putting changes into a copy of the map directly.
But today as the “domain” (that is how I called the bounds, I was missing the “bounds” word) keeps growing, it is faster to recalculate max bounds instead of scanning the whole new map ; the changes is already a list and is smaller.
However, I use this code (this is for part 1). The 2nd argument is the coordinates for a cube that has just been activated.
This is a lot of calls to
min/1andmax/1for each change. I guess using pattern matching and recursion until the domain includes the coordinates of an active point could be better.Today, seeing that part 2 was not “run 3’000’000 cycles” was a bit disappointing but also a relief
my solution
mruoss
Read it over and over… nope, I still don’t get it.
The top left coordinate of the z0 layer has 1 active satellite in the “before any cycles”. But it is active in the “After 1 cycle”. So you’re saying they move around. Where is that movement described?
Hallski
They patched the text just above the graphs and added
(and the frame of view follows the active cells in each cycle)as lots of people got confused.I ended up ignoring the graphs all together as they didn’t really help me in any way.
mruoss
Oh boy, I get it now! I was looking for something in the instructions, but it’s how the examples are displayed. The frame of view is moving!
I could have ignored the examples but it bothered me that my understanding after which I write the algorithm wouldn’t even comply with the example. Alright… let’s see where to find the motivation to solve this now…
Papey
We may have to found a way to generate/generalize this to n-dimension, this one was just to ensure everyone is ready, I think.
akash-akya
Took sometime to make it generic, so it can work with
ndimensions (not really required though). Relatively easy part two this time