-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfindmax.py
32 lines (27 loc) · 1.18 KB
/
findmax.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
import calcproduct, parsetoarray
def findmax(numbersfile, numprod):
arrayin = parsetoarray.parsetoarray(numbersfile)
max = 0
for directions in [[0, 1], [1, 0], [1, 1], [-1, 1]]:
for starty in range(len(arrayin)):
for startx in range(len(arrayin[0])):
currentstart = [starty, startx]
if ((currentstart[0] > len(arrayin) - numprod and
directions[0] == 1) or
(currentstart[1] > len(arrayin[0]) - numprod and
directions[1] == 1) or
(currentstart[0] < numprod -1 and
directions[0] == -1)):
#(currentstart[1] > len(arrayin[0]) - numprod and
#directions[1] == 1)):
break
curprod = calcproduct.calcproduct(arrayin, currentstart, directions, numprod)
#print ([currentstart[0], currentstart[1]])
if curprod > max:
max = curprod
finalstart = currentstart
finaldirections = directions
print "finalstart, directions = "
print finalstart
print finaldirections
return max