Skip to content

Instantly share code, notes, and snippets.

@thomasaarholt
Created December 2, 2020 08:55
Show Gist options
  • Save thomasaarholt/dd2ddfdf113adecc3a9a50a4ff4bb7a4 to your computer and use it in GitHub Desktop.
Save thomasaarholt/dd2ddfdf113adecc3a9a50a4ff4bb7a4 to your computer and use it in GitHub Desktop.
Python Solution to Advent of Code Day 01
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