Repository navigation
Expand file tree
/
Copy patheuler-011.py
More file actions
51 lines (42 loc) · 2.62 KB
/
Copy patheuler-011.py
File metadata and controls
51 lines (42 loc) · 2.62 KB
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
# -*- coding: utf-8 -*-
"""
Created on Sat Jun 10 04:17:41 2017
@author: Steven
"""
grid = "08022297381500400075040507785212507791084949994017811857608717409843694804566200814931735579142993714067538830034913366552709523046011426924685601325671370236912231167151676389419236542240402866331380244732609903450244753353783684203517125032988128642367102638406759547066183864706726206802621220956394396308409166499421245558056673992697177878968314883489637221362309750076442045351400613397343133957817532822753167159403800462161409535692163905429635314755588824001754243629855786560048357189070544443744602158515417581980816805944769287392138652177704895540045208839735991607975732162626793327986688366887576220720346336746551232639353690442167338253911249472180846293240627636206936417230238834629969826759857404361620733529783190017431497148868116235705540170547183515469169233486143520189196748"
matrix = [[0] * 20 for i in range(20)]
x = 0
y = 0
product = 1
for i in range(0,len(grid)-1,2):
matrix[x][y] = int(grid[i:i+2])
y += 1
if y >= 20:
y = 0
x += 1
# Search Vertical
for y in range(0,1):
for x in range(0,17):
if (matrix[x][y] * matrix[x+1][y] * matrix[x+2][y] * matrix[x+3][y]) > product:
product = (matrix[x][y] * matrix[x+1][y] * matrix[x+2][y] * matrix[x+3][y])
print("Vertical - %d * %d * %d * %d = %d" % (matrix[x][y], matrix[x+1][y], matrix[x+2][y], matrix[x+3][y], product))
# Search Horizontal
for x in range(0,20):
for y in range(0,17):
if (matrix[x][y] * matrix[x][y+1] * matrix[x][y+2] * matrix[x][y+3]) > product:
product = (matrix[x][y] * matrix[x][y+1] * matrix[x][y+2] * matrix[x][y+3])
print("Horizontal - %d * %d * %d * %d = %d" % (matrix[x][y],matrix[x][y+1],matrix[x][y+2],matrix[x][y+3], product))
# Search Diagonal Right
for x in range(0,17):
for y in range(0,17):
if (matrix[x][y] * matrix[x+1][y+1] * matrix[x+2][y+2] * matrix[x+3][y+3]) > product:
product = (matrix[x][y] * matrix[x+1][y+1] * matrix[x+2][y+2] * matrix[x+3][y+3])
print("Diagonal Right - %d * %d * %d * %d = %d" % (matrix[x][y], matrix[x+1][y+1], matrix[x+2][y+2], matrix[x+3][y+3], product))
# Search Diagonal Left
for y in range(3,20):
for x in range(0,17):
if (matrix[x][y] * matrix[x+1][y-1] * matrix[x+2][y-2] * matrix[x+3][y-3]) > product:
product = (matrix[x][y] * matrix[x+1][y-1] * matrix[x+2][y-2] * matrix[x+3][y-3])
print("Diagonal Left - %d * %d * %d * %d = %d" % (matrix[x][y], matrix[x+1][y-1], matrix[x+2][y-2], matrix[x+3][y-3], product))
#print(product)
#print(matrix[1][2])