]> git.sommitrealweird.co.uk Git - advent-of-code-2020.git/blob - day01/find_2020_factors_2.py
Day 14 - implemented in bash, because, well, I could
[advent-of-code-2020.git] / day01 / find_2020_factors_2.py
1 #!/usr/bin/python3
2
3 import sys
4
5 data = [int(a) for a in open("input.txt", "r").read().split("\n") if a != '']
6
7 for i in range(0,len(data)-3):
8     for j in range(i+1,len(data)-2):
9         for k in range(i+2, len(data)-1):
10             if data[i] + data[j] + data[k] == 2020:
11                 print("Match found: ", data[i], " + ", data[j], " + ", data[k], " = 2020")
12                 print("Multiplied: ", data[i] * data[j] * data[k])
13                 sys.exit(0)