Arxcis / adventofcode2020

Community-project solving https://adventofcode.com/ - problems, with Github CI, Docker and support for many languages.
6 stars 8 forks source link

Day 17 - Convay cubes complications #115

Closed Arxcis closed 3 years ago

Arxcis commented 3 years ago

Merry christmas 🎄 🎅

I just don't get this day https://adventofcode.com/2020/day/17

Rules During a cycle, all cubes simultaneously change their state according to the following rules:

Example

Before any cycles:

z=0
.#.
..#
###

After 1 cycle:

z=-1
#..
..#
.#.

z=0
#.#
.##
.#.

z=1
#..
..#
.#.

My attempt at making sense of it Let's consider z=0 initial state:

z=0
.#.
..#
###

And here is me applying the rules for each cell from left to right, top to bottom:

  1. Is inactive and has 1 active neighbor to the right -> remains inactive
  2. Is active and has 1 active neighbor to the bottom right -> turns to inactive
  3. Is inactive and has 2 active neighbors -> remains inactive
  4. Is inactive and has 3 active neighbor -> turns to active
  5. Is inactive and has 4 active neighbors -> remains active
  6. Is active and has 3 active neighbors -> remains active
  7. Is active and has 1 active neighbor -> turns to inactive
  8. Is active and has 3 active neighbors -> remains active
  9. Is active and has 2 active neightbors -> remains active

What I expected z=0 to be after 1 cycle

z=0
...
#.#
.##

Example after 1 cycle

After 1 cycle:
z=0
#.#
.##
.#.

What Is going on here? I have been completely stuck on this task for several days because I don't get it.

hypirion commented 3 years ago

Each cube only ever considers its neighbors: any of the 26 other cubes where any of their coordinates differ by at most 1.

So for t=0, given we start with this at z=0:

.....
..#..
...#.
.###.
.....

Assuming no active for z != 0, then the one at the center of this piece:

..#
...
.##

has 3/28 active neighbours, and turns active.

This one

#..
.#.
##.

Has 3/28 active neighbours, and stays active.

This one

.#.
##.
...

Has only 2/28 active neighbours, but stays active, as it already was active.


The entire grid for z=0 at t=1 then becomes

.....
.....
.#.#.
..##.
..#..

Notice the shift in location, the example in the text doesn't add the padding around that I've done here.

Arxcis commented 3 years ago

Aha! I was stuck with a 3x3 mindset. The solution for me, which you presented clearly @hypirion - thank you very much, is that I had to think 5x5 from the begnning.

I had a mistake in my initial explanation above, which I have corrected now, which makes it more obvious that the example has shifted it's view one step down. I was not thinking outside the box enough 😅

Corrected:

What I expect z=0 to be after 1 cycle

z=0
...
#.#
.##

Example after 1 cycle

After 1 cycle:
z=0
#.#
.##
.#.