summary refs log tree commit diff stats
path: root/day20.py
diff options
context:
space:
mode:
authorBrian Chu <brianmchu42@gmail.com>2021-12-30 15:11:21 -0800
committerBrian Chu <brianmchu42@gmail.com>2021-12-30 15:11:21 -0800
commite7085453864431ace3ad8f3123b259ed0829ae74 (patch)
tree2ef1fbb0e9d02fc934b5e09d96dd187f3e371ea6 /day20.py
downloadAdventOfCode2015-main.tar.gz
all solutions for 2015 main
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