2018-12-05 15:22:54 +10:30
|
|
|
import numpy as np
|
2018-12-07 12:11:43 +10:30
|
|
|
max_it = 1000000 # Arbitrarily large number, increase if it fails.
|
2018-12-05 15:22:54 +10:30
|
|
|
input = 33100000
|
|
|
|
|
|
|
|
houses = np.ones([max_it], dtype=np.int64)
|
|
|
|
pres10 = input//10
|
|
|
|
for i in range(2, max_it):
|
|
|
|
houses[i::i] += i
|
|
|
|
print(np.argmax(houses > pres10)) # Part 1
|
|
|
|
|
2018-12-07 12:11:43 +10:30
|
|
|
houses_2 = np.zeros([max_it], dtype=np.int64) # Can no longer optimise out first elf
|
2018-12-05 15:22:54 +10:30
|
|
|
pres11 = input//11
|
2018-12-07 12:11:43 +10:30
|
|
|
for i in range(1, max_it):
|
2018-12-05 15:22:54 +10:30
|
|
|
houses_2[i:i*51:i] += i
|
|
|
|
print(np.argmax(houses_2 > pres11)) # Part 2
|