summary refs log blame commit diff stats
path: root/day20.py
blob: f8cf55dcdd77192dab72d9dac60d82eceda7c4c1 (plain) (tree)




















                                                                                 
#!/usr/bin/env python

from functools import reduce

def divisors(n):
    return set(reduce(list.__add__,
                      ([i, n//i] for i in range(1, int(n**0.5) + 1) if n%i==0 )))

n = 1
total = 29000000
while True:
    if sum(divisors(n)) * 10 >= total:
        print(n)
        break
    n += 1

while True:
    if sum(d for d in divisors(n) if n / d <= 50) * 11 >= total:
        print(n)
        break
    n += 1