-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheuler28.py
58 lines (52 loc) · 1.21 KB
/
euler28.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
def makebox(n):
ls=[]
for i in range(n+1):
ls.append([])
temp=ls[:]
for i in range(len(ls)):
ls[i]=temp[:]
order=['r','d','l','u']
start=(n/2)
steps=1
a=start
b=start
c=1
ls[a][b]=c
while c<(n*n):
for i in range(2):
if order[0]=='r':
for i in range(steps):
b+=1
c+=1
ls[a][b]=c
elif order[0]=='d':
for i in range(steps):
a+=1
c+=1
ls[a][b]=c
elif order[0]=='l':
for i in range(steps):
b-=1
c+=1
ls[a][b]=c
elif order[0]=='u':
for i in range(steps):
a-=1
c+=1
ls[a][b]=c
order.append(order.pop(0))
steps+=1
for i in range(n):
ls[i].pop(-1)
ls.pop(-1)
# for i in range(n):
# print ls[i]
return ls
def summed(box):
n=0
for i in range(len(box)):
n+=box[i][i]
for i in range(len(box)):
n+=box[len(box)-1-i][i]
n-=1
return n