Vectorised Part 2 2018 Day 11 SAT

This commit is contained in:
Luke Hubmayer-Werner 2018-12-12 11:20:49 +10:30
parent a4701ac168
commit 2c6235013e
1 changed files with 10 additions and 5 deletions

View File

@ -39,10 +39,15 @@ max_power_s = 0
max_idx_s = (0,0,0) max_idx_s = (0,0,0)
for x in range(1, 298): for x in range(1, 298):
for y in range(1, 298): for y in range(1, 298):
for s in range(4, 302-max(x, y)): A = fuel_cs[x-1, y-1]
val = sum_square(x, y, s) Ds = fuel_cs[x+3:, y+3:].diagonal()
if val > max_power_s: Bs = fuel_cs[x+3:, y-1][:len(Ds)]
max_power_s = val Cs = fuel_cs[x-1, y+3:][:len(Ds)]
max_idx_s = (x, y, s) sums = Ds - Cs - Bs + A
idx = sums.argmax()
val = sums[idx]
if val > max_power_s:
max_power_s = val
max_idx_s = (x, y, 4+idx)
print(max_idx_s) # Part 2 print(max_idx_s) # Part 2