summary refs log tree commit diff stats
path: root/day20.py
diff options
context:
space:
mode:
Diffstat (limited to 'day20.py')
-rw-r--r--day20.py21
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