Skip to content

Instantly share code, notes, and snippets.

@alexgreenbank
Last active December 1, 2020 14:59
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 alexgreenbank/55daaa31c84974e1971af2e40e207784 to your computer and use it in GitHub Desktop.
Save alexgreenbank/55daaa31c84974e1971af2e40e207784 to your computer and use it in GitHub Desktop.
AoC 2020 Day 1 python
#!/usr/bin/python
# Use a set rather than a dict
nos = {int(line) for line in open('1.inp', 'r')}
# Part 1
for e in nos:
if (2020-e) in nos:
print(e, (2020-e), e * (2020-e) )
break
# Part 2
for e in nos:
for f in nos:
if (2020-e-f) in nos:
print(e, f, (2020-e-f), e * f * (2020-e-f) )
exit()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment