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:
Left | Center | Right |
---|---|---|
1 | 1 | 0 |
0 | 1 | 1 |
1 | 0 | 0 |
0 | 0 | 1 |
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§
- count 🔒