about summary refs log tree commit diff
path: root/users/Profpatsch/advent-of-code/2020/01/main.py
diff options
context:
space:
mode:
authorProfpatsch <mail@profpatsch.de>2021-02-27T20·46+0100
committerProfpatsch <mail@profpatsch.de>2021-02-27T20·48+0000
commitace8c656befb37ddb558836d4787a775331c78f3 (patch)
tree0d272ddfd9958bb236449e0168cff5d891c82304 /users/Profpatsch/advent-of-code/2020/01/main.py
parentf3d00b84bb65ae344a28e1bebfb5ce8b0efff8d1 (diff)
feat(users/Profpatsch): add advent of code 2020 day 1 2 3 r/2245
Change-Id: I99d2882ac9ef5ede85032132f6727e7bad8f24eb
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2564
Tested-by: BuildkiteCI
Reviewed-by: Profpatsch <mail@profpatsch.de>
Diffstat (limited to 'users/Profpatsch/advent-of-code/2020/01/main.py')
-rw-r--r--users/Profpatsch/advent-of-code/2020/01/main.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/users/Profpatsch/advent-of-code/2020/01/main.py b/users/Profpatsch/advent-of-code/2020/01/main.py
new file mode 100644
index 000000000000..e636017a54d5
--- /dev/null
+++ b/users/Profpatsch/advent-of-code/2020/01/main.py
@@ -0,0 +1,22 @@
+import sys
+
+l = []
+with open('./input', 'r') as f:
+    for line in f:
+        l.append(int(line))
+
+s = set(l)
+
+res=None
+for el in s:
+    for el2 in s:
+        if (2020-(el+el2)) in s:
+            res=(el, el2, 2020-(el+el2))
+            break
+
+if res == None:
+    sys.exit("could not find a number that adds to 2020")
+
+print(res)
+
+print(res[0] * res[1] * res[2])