Module aoc::year2023::day13

source ยท
Expand description

ยงPoint of Incidence

We store each row of a grid as a binary number. For example #.##..##. becomes 101100110. Then to count smudges we bitwise XOR the respective rows together and count one bits using the count_ones function.

For example:

    ..##..###     001100111 ^ 000100111 = 00100000 => 1
   v#####.##.v => 111110110 ^ 111110110 = 00000000 => 0
   ^#####.##.^
    ...#..###

To handle columns we transpose the grid then convert into integers the same way. For part one we look for a reflection axis with 0 smudges and for part two 1 smudge, allowing the same code to be reused.

Functionsยง

Type Aliasesยง