From 3b529916d2022098a1fef6b1e3c81b2952b7dd16 Mon Sep 17 00:00:00 2001 From: Ben Charlton Date: Wed, 2 Dec 2020 18:29:29 +0000 Subject: [PATCH] day 1 --- 01/01.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 01/01.py diff --git a/01/01.py b/01/01.py new file mode 100644 index 0000000..21170f9 --- /dev/null +++ b/01/01.py @@ -0,0 +1,24 @@ +#!/usr/bin/python3 + +import sys + +ints = [] +for line in sys.stdin: + ints.append(int(line.rstrip())) + +p = range(0, len(ints)) +# Inefficient, but fast enough. +for x in p: + for y in p: + if x == y: + continue + + for z in p: + if x == z or y == z: + continue + + if ints[x] + ints[y] + ints[z] == 2020: + print (2, ints[x] * ints[y] * ints[z]) + + if ints[x] + ints[y] == 2020: + print (1, ints[x] * ints[y]) \ No newline at end of file