-
Notifications
You must be signed in to change notification settings - Fork 0
/
problem_11.py
54 lines (38 loc) · 848 Bytes
/
problem_11.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
53
54
with open('problem_11_resource.txt', 'rb') as raw_data:
data = []
for row in raw_data:
data.append(row.split())
greatest_product = 0
def product_find():
global greatest_product
if product > greatest_product:
greatest_product = product
# Horizontal
for row in data:
for i in range(17):
product = 1
for n in range(4):
product *= int(row[n + i])
product_find()
# Vertical
for x in range(20):
for y in range(16):
product = 1
for n in range(4):
product *= int(data[x][y + n])
product_find()
#Diagonal Right
for x in range(17):
for y in range(17):
product = 1
for n in range(4):
product *= int(data[x + n][y + n])
product_find()
#Diagonal Left
for x in range(3, 20):
for y in range(17):
product = 1
for n in range(4):
product *= int(data[x - n][y + n])
product_find()
print greatest_product