-
Notifications
You must be signed in to change notification settings - Fork 0
/
11b.py
59 lines (44 loc) · 922 Bytes
/
11b.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
file_name = "10a.txt"
import numpy as np
np.set_printoptions(threshold=np.nan)
import re
def calc(x,y):
serial = 3628
rackid = x + 10
pl = rackid * y
pl = (pl + serial) * rackid
if len(str(pl)) < 3:
return -5
else:
return int(str(pl)[len(str(pl))-3]) - 5
def box(base_arr, x,y,s):
y = y-1
x = x-1
sli = base_arr[y:y+s, x:x+s]
return sli.sum()
def preprocess():
maxval = 0
maxcoords = 0,0
maxsize = 0
base_arr = np.zeros(( 300, 300 ))
for x in range(1,301):
for y in range(1,301):
base_arr.itemset((y-1,x-1), calc(x,y))
for x in range(1,301):
print(x)
for y in range(1,301):
xymax = max(x,y)
for s in range(xymax,300):
s = s - xymax
val = box(base_arr,x,y,s)
if val > maxval:
maxval = val
maxcoords = x,y
maxsize = s
print('maxcoords ', maxcoords)
print('maxsize ', maxsize)
print('maxval ', maxval)
return
def main():
preprocess()
main()