DEV Community

Nick Brunner
Nick Brunner

Posted on

Advent of Code 2020 - Day 1

Here is my solution for Day 1:

with open('input.txt') as file:
    input = file.readlines()

puzzle_input = [int(line.strip()) for line in input]

for i in range(0, len(puzzle_input)):
    for j in range(i+1, len(puzzle_input)):
        for k in range(j+1, len(puzzle_input)):
            if (puzzle_input[i] + puzzle_input[j] + puzzle_input[k] == 2020):
                print(f'Answer: {puzzle_input[i]*puzzle_input[j]*puzzle_input[k]}')
Enter fullscreen mode Exit fullscreen mode

You can also view my solution on my GitHub.

How did you do?

Discussion (0)