Some pretty horrific programming here...
Iterate through every combination of vertical, horizontal, and diagonal checking for XMAS
or SAMX
.
Count every occurence.
Iterate through grid finding any A
character - get all corners of 3x3 grid centered by A
character.
Validate that diagonals in grid are opposing letters, e.g., if upper left is M
then bottom right must be S
.