I am also gonna be doing aoc this year. Here is my Python solution:
with open("input.txt") as f: l = [int(x.strip()) for x in f] for i, n1 in enumerate(l): for j, n2 in enumerate(l[i+1:]): if n1 + n2 == 2020: part1 = n1 * n2 for n3 in l[i+j+1:]: if n1 + n2 + n3 == 2020: part2 = n1 * n2 * n3 print(part1) print(part2)
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
I am also gonna be doing aoc this year. Here is my Python solution: