Solve 2015 days 20-22.
This commit is contained in:
28
2015/d20.py
Normal file
28
2015/d20.py
Normal file
@@ -0,0 +1,28 @@
|
||||
from itertools import combinations
|
||||
import lib
|
||||
|
||||
data = int(open(0).read().strip())
|
||||
part_1 = False
|
||||
|
||||
def calc(n):
|
||||
fs = lib.prime_factors(n)
|
||||
vs = set([1, n])
|
||||
for i in range(1, len(fs) + 1):
|
||||
for c in combinations(fs, i):
|
||||
p = 1
|
||||
for e in c:
|
||||
p *= e
|
||||
vs.add(p)
|
||||
r = 0
|
||||
for e in vs:
|
||||
if part_1:
|
||||
r += e * 10
|
||||
elif n <= e * 50:
|
||||
r += e * 11
|
||||
return r
|
||||
|
||||
for i in range(3, 10000000):
|
||||
c = calc(i)
|
||||
if c >= data:
|
||||
print(i)
|
||||
break
|
||||
Reference in New Issue
Block a user