pub struct Day17 { /* private fields */ }Expand description
2020 Day 17: Simulating a cellular automaton in three and four dimensions.
The key optimization is that the initial state is at z = w = 0 and the update rule treats all directions the same, so layers z and -z are always equal, as well as w and -w, and (z, w) and (w, z). Therefore, only layers with z >= 0 for part 1 and 0 <= w <= z for part 2 are simulated.
Each cycle first counts the neighbours of each cell within its own layer, then adds the counts from the adjacent w and z layers to get each cell’s total.
Implementations§
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Day17
impl RefUnwindSafe for Day17
impl Send for Day17
impl Sync for Day17
impl Unpin for Day17
impl UnsafeUnpin for Day17
impl UnwindSafe for Day17
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more