aoc2024/d04/part2.py

17 lines
429 B
Python
Raw Permalink Normal View History

2024-12-04 09:11:37 +00:00
import sys, os
L = sys.stdin.read().strip().split("\n")
G = [list(l) for l in L]
H = len(G)
W = len(G[0])
S = 0
for i in range(1,H-1): # rows
for j in range(1, W-1): # cols
if G[i][j] == "A":
for P in ["MMSS", "SMMS", "SSMM", "MSSM"]:
if G[i-1][j-1] == P[0] and G[i-1][j+1] == P[1] \
and G[i+1][j+1] == P[2] and G[i+1][j-1] == P[3]:
S+=1
print(S)