-
-
Save alexgreenbank/55daaa31c84974e1971af2e40e207784 to your computer and use it in GitHub Desktop.
AoC 2020 Day 1 python
This file contains 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
#!/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