A golfed Python script that reads the input from stdin and prints both parts to stdout with a space between
*l,g=*open(0),lambda i,j:l[i][j]if len(l)>i>-1<j<len(l[i
])else"";e,*d=enumerate,-1,0,1;print(*map(sum,zip(*((all
(c==g(i+n*x,j+n*y)for n,c in e("XMAS")),x!=0!=y!=c=="A"<
"M"==g(i-x,j-y)==g(i-y,j+x)<"S"==g(i+x,j+y)==g(i+y,j-x))
for i,m in e(l)for j,c in e(m)for x in d for y in d))))
and a golfed Uiua program that reads from 04.txt, leaving both answers on the stack (which is implicitly printed at the end). You can drag and drop an input file called 04.txt straight onto it to solve it.
from operator import*;O=add,mul
C=[(int(a[:-True]),[*map(int,b)])for a,*b in map(str.split,open(False))]
g=lambda l,i=-True:{o(v,l[i])for v in g(l,~-i%len(l))for o in O}if i else{l[i]}
for p in O:print(sum(c*(c in g(n))for c,n in C));O+=lambda*a:int("%d%d"%a),
(reads from stdin
, prints parts one and two on separate lines)
Here's my setup - a pair of 24 inch 1080p monitors, with a vertical monitor on the left for the puzzle and a horizontal monitor on the right for my IDE of choice, VS Code. Within VS Code I have a few terminals: The one on the left runs some custom scripts (sleep_until.py and fetch_input.py) for getting the input and displaying the first few lines, and the one on the right runs my script (using when-changed) when the script or input file changes (which beats switching to the terminal and hitting up & enter). I built this PC a few months ago (since my laptop was getting a little past it) - It runs an Intel 12400 and a Radeon RX 6600 with 32 GB of RAM (just a little shy of the 2 PB needed for day 11). The PC has a large family of rubber ducks atop it, including four very festive ducks. Not shown in the picture is the fan behind my chair. My office is upstairs which frequently reaches 30°C (86°F) (in fact, it's 26°C as I write this at 2 A.M.)
As always, all my code is in my repo. I've solved everything in Python (though 24.2 is still somewhat manual) and everything except 24.2 in Uiua