Skip to main content

Module day04

Module day04 

Source
Expand description

For part one we search each vertical, horizontal and diagonal direction one at a time over the whole grid, checking for both “XMAS” and “SAMX” at every position. The newline padding prevents false positives at boundaries.

For part two the difference of the ASCII values of “M” and “S” is 6. No other combination of letters has this value, so if both diagonals are 6 then we have a match.

Both parts are written without branches, so the compiler auto-vectorizes each loop.

Functions§

parse
part1
part2