diff options
author | Brian Chu <brianmchu42@gmail.com> | 2021-12-30 15:11:21 -0800 |
---|---|---|
committer | Brian Chu <brianmchu42@gmail.com> | 2021-12-30 15:11:21 -0800 |
commit | e7085453864431ace3ad8f3123b259ed0829ae74 (patch) | |
tree | 2ef1fbb0e9d02fc934b5e09d96dd187f3e371ea6 /day20.py | |
download | AdventOfCode2015-e7085453864431ace3ad8f3123b259ed0829ae74.tar.gz |
all solutions for 2015 main
Diffstat (limited to 'day20.py')
-rw-r--r-- | day20.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/day20.py b/day20.py new file mode 100644 index 0000000..f8cf55d --- /dev/null +++ b/day20.py @@ -0,0 +1,21 @@ +#!/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 |