Added 2015 day20
This commit is contained in:
parent
681d0ddfa9
commit
956d461e3d
|
@ -1,8 +1,15 @@
|
||||||
for i in range(1, 500001):
|
import numpy as np
|
||||||
presents = 0
|
max_it = 813960 # Somewhat cheaty - this value was obtained from an earlier factor-based brute force. Just use an arbitrarily large number if it fails.
|
||||||
for n in range(1, i+1):
|
input = 33100000
|
||||||
if i%n == 0:
|
|
||||||
presents += 10*n
|
houses = np.ones([max_it], dtype=np.int64)
|
||||||
if presents >= 33100000:
|
pres10 = input//10
|
||||||
print(i, presents)
|
for i in range(2, max_it):
|
||||||
break
|
houses[i::i] += i
|
||||||
|
print(np.argmax(houses > pres10)) # Part 1
|
||||||
|
|
||||||
|
houses_2 = np.ones([max_it], dtype=np.int64)
|
||||||
|
pres11 = input//11
|
||||||
|
for i in range(2, max_it):
|
||||||
|
houses_2[i:i*51:i] += i
|
||||||
|
print(np.argmax(houses_2 > pres11)) # Part 2
|
||||||
|
|
Loading…
Reference in New Issue