Skip to content

Instantly share code, notes, and snippets.

@rtt
Created December 1, 2020 15:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rtt/17221e7653c5ceb1c96ceb9ee4f364f0 to your computer and use it in GitHub Desktop.
Save rtt/17221e7653c5ceb1c96ceb9ee4f364f0 to your computer and use it in GitHub Desktop.
advent of code 2020 - day 1
def get_input():
with open('1.txt') as f:
inp = f.readlines()
return list(map(int, map(str.strip, filter(None, inp))))
def get_answer():
expenses = get_input()
seen = set()
while expenses:
curr = expenses.pop()
for val in seen:
if val + curr == 2020:
return val * curr
seen.add(curr)
if __name__ == '__main__':
print(get_answer())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment