-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path7.py
52 lines (46 loc) · 1.7 KB
/
7.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
from collections import defaultdict
sum = 0
puzzle_raw = []
puzzle = defaultdict(lambda: "")
f = open("7.in")
for line in f.readlines():
puzzle_raw.append(list(line))
for x in range(len(puzzle_raw)):
for y in range(len(puzzle_raw[x])):
puzzle[(x, y)] = puzzle_raw[x][y]
for x in range(len(puzzle_raw)):
for y in range(len(puzzle_raw[x])):
if puzzle[(x,y)] == "X":
if puzzle[(x+1,y)] == "M":
if puzzle[(x+2,y)] == "A":
if puzzle[(x+3,y)] == "S":
sum += 1
if puzzle[(x-1,y)] == "M":
if puzzle[(x-2,y)] == "A":
if puzzle[(x-3,y)] == "S":
sum += 1
if puzzle[(x,y+1)] == "M":
if puzzle[(x,y+2)] == "A":
if puzzle[(x,y+3)] == "S":
sum += 1
if puzzle[(x,y-1)] == "M":
if puzzle[(x,y-2)] == "A":
if puzzle[(x,y-3)] == "S":
sum += 1
if puzzle[(x+1,y+1)] == "M":
if puzzle[(x+2,y+2)] == "A":
if puzzle[(x+3,y+3)] == "S":
sum += 1
if puzzle[(x-1,y-1)] == "M":
if puzzle[(x-2,y-2)] == "A":
if puzzle[(x-3,y-3)] == "S":
sum += 1
if puzzle[(x+1,y-1)] == "M":
if puzzle[(x+2,y-2)] == "A":
if puzzle[(x+3,y-3)] == "S":
sum += 1
if puzzle[(x-1,y+1)] == "M":
if puzzle[(x-2,y+2)] == "A":
if puzzle[(x-3,y+3)] == "S":
sum += 1
print(sum)