diff options
author | Nguyễn Gia Phong <cnx@loang.net> | 2024-12-04 15:22:35 +0900 |
---|---|---|
committer | Nguyễn Gia Phong <cnx@loang.net> | 2024-12-04 15:22:35 +0900 |
commit | b65dedcebd761653d8295e4b9356b4eef8e3ca02 (patch) | |
tree | 808a24e37e215fb59c1cf5ad1a0db0c3b48b088c /aoc/2024/04/part-two.py | |
parent | 8026395b987f440486e215f77e402eafc94160f0 (diff) | |
download | cp-b65dedcebd761653d8295e4b9356b4eef8e3ca02.tar.gz |
[aoc/2024] Finish day 4
Diffstat (limited to 'aoc/2024/04/part-two.py')
-rw-r--r-- | aoc/2024/04/part-two.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/aoc/2024/04/part-two.py b/aoc/2024/04/part-two.py new file mode 100644 index 0000000..a3e7c4a --- /dev/null +++ b/aoc/2024/04/part-two.py @@ -0,0 +1,10 @@ +from itertools import islice +from sys import stdin + +mat = tuple(map(str.strip, stdin.readlines())) +m = len(mat) +n = len(mat[0]) +print(sum(c == 'A' and ({mat[i-1][j-1], mat[i+1][j+1]} + == {mat[i-1][j+1], mat[i+1][j-1]} == {'M', 'S'}) + for i, line in islice(enumerate(mat), 1, m-1) + for j, c in islice(enumerate(line), 1, n-1))) |