Created
December 2, 2020 08:55
-
-
Save thomasaarholt/dd2ddfdf113adecc3a9a50a4ff4bb7a4 to your computer and use it in GitHub Desktop.
Python Solution to Advent of Code Day 01
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
with open("input01.txt") as f: | |
a = f.read() | |
data = np.array([int(n) for n in a.split("\n")[:-1]]) | |
def first(data): | |
for i, number in enumerate(data): | |
for number2 in data[i:]: | |
if number + number2 == 2020: | |
print(f"Part 1: {number*number2}") | |
for number3 in data[i+1:]: | |
if number + number2 + number3 == 2020: | |
print(f"Part 2: {number*number2*number3}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment