Expand description
§Ceres Search
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.