Day 1
This commit is contained in:
parent
047a183f60
commit
8b035ab9b6
20
2020/day1.py
Normal file
20
2020/day1.py
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
import itertools
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
with open("day1.txt", "rt") as f:
|
||||||
|
lines = [line.rstrip() for line in f.readlines()]
|
||||||
|
values = list(map(lambda l: int(l), lines))
|
||||||
|
|
||||||
|
# Part 1
|
||||||
|
for a, b in itertools.combinations(values, 2):
|
||||||
|
if a + b == 2020:
|
||||||
|
print(a * b)
|
||||||
|
# Part 2
|
||||||
|
for a, b, c in itertools.combinations(values, 3):
|
||||||
|
if a + b + c == 2020:
|
||||||
|
print(a * b * c)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
7
2020/skel.py.txt
Normal file
7
2020/skel.py.txt
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
def main():
|
||||||
|
with open("", "rt") as f:
|
||||||
|
lines = [line.rstrip() for line in f.readlines()]
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
Loading…
Reference in a new issue