2018 Day 11 unoptimised

This commit is contained in:
Luke Hubmayer-Werner 2018-12-11 16:14:11 +10:30
parent e8fe7e5152
commit 4657683077
1 changed files with 38 additions and 0 deletions

38
2018/day11.py Normal file
View File

@ -0,0 +1,38 @@
import numpy as np
input = 4455
fuel_cells = np.zeros((300,300), dtype=np.int64)
for y in range(300):
fuel_cells[:,y] = y+1
for x in range(300):
fuel_cells[x,:] *= x+11
fuel_cells += input
for x in range(300):
fuel_cells[x,:] *= x+11
fuel_cells //= 100
fuel_cells %= 10
fuel_cells -= 5
max_power = 0
max_idx = (0,0)
for x in range(298):
for y in range(298):
val = fuel_cells[x:x+3, y:y+3].sum()
if val > max_power:
max_power = val
max_idx = (x+1,y+1)
print(max_idx) # Part 1
max_power = 0
max_idx = (0,0,0)
for x in range(298):
for y in range(298):
for s in range(3, 301-max(x,y)):
val = fuel_cells[x:x+s, y:y+s].sum()
if val > max_power:
max_power = val
max_idx = (x+1,y+1,s)
print(max_idx) # Part 2