forked from kothariji/competitive-programming
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path011. Largest product in a grid.py
69 lines (63 loc) · 1.54 KB
/
011. Largest product in a grid.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
s1 = input()
s2 = input()
s3 = input()
s4 = input()
s5 = input()
s6 = input()
s7 = input()
s8 = input()
s9 = input()
s10 = input()
s11 = input()
s12 = input()
s13 = input()
s14 = input()
s15 = input()
s16 = input()
s17 = input()
s18 = input()
s19 = input()
s20 = input()
l = []
l.append(list(s1.split()))
l.append(list(s2.split()))
l.append(list(s3.split()))
l.append(list(s4.split()))
l.append(list(s5.split()))
l.append(list(s6.split()))
l.append(list(s7.split()))
l.append(list(s8.split()))
l.append(list(s9.split()))
l.append(list(s10.split()))
l.append(list(s11.split()))
l.append(list(s12.split()))
l.append(list(s13.split()))
l.append(list(s14.split()))
l.append(list(s15.split()))
l.append(list(s16.split()))
l.append(list(s17.split()))
l.append(list(s18.split()))
l.append(list(s19.split()))
l.append(list(s20.split()))
max1 = 0
for i in range(0,20):
for j in range(0,17):
mul = int(l[i][j])*int(l[i][j+1])*int(l[i][j+2])*int(l[i][j+3])
if mul > max1:
max1 = mul
for i in range(0,20):
for j in range(0,17):
mul = int(l[j][i])*int(l[j+1][i])*int(l[j+2][i])*int(l[j+3][i])
if mul > max1:
max1 = mul
for i in range(0,17):
for j in range(0,17):
mul = int(l[i][j])*int(l[i+1][j+1])*int(l[i+2][j+2])*int(l[i+3][j+3])
if mul > max1:
max1 = mul
for i in range(0,17):
for j in range(3,20):
mul = int(l[i][j])*int(l[i+1][j-1])*int(l[i+2][j-2])*int(l[i+3][j-3])
if mul > max1:
max1 = mul
print(max1)