Module aoc::year2016::day18

source ·
Expand description

§Like a Rogue

We represent a trap with a 1 bit and a safe tile with a 0 bit storing the entire row in a u128. We then use bitwise logic to calculate the next row.

Writing out the truth table for the rules:

LeftCenterRight
110
011
100
001

We can see that the value of the center doesn’t matter and that the next tile will be a trap if the left and right values are different. We calculate this for all traps at the same time with a bitwise XOR.

Functions§