add second part of solution 1
This commit is contained in:
parent
458e998c3d
commit
64388e3881
|
@ -0,0 +1,6 @@
|
||||||
|
1721
|
||||||
|
979
|
||||||
|
366
|
||||||
|
299
|
||||||
|
675
|
||||||
|
1456
|
|
@ -2,12 +2,23 @@
|
||||||
|
|
||||||
fd = open("input", "r")
|
fd = open("input", "r")
|
||||||
lines = fd.readlines()
|
lines = fd.readlines()
|
||||||
|
lines = [i.rstrip() for i in lines]
|
||||||
mustbreak = False
|
mustbreak = False
|
||||||
|
|
||||||
|
def part1():
|
||||||
for i in lines:
|
for i in lines:
|
||||||
for j in lines:
|
for j in lines:
|
||||||
if int(i) + int(j) == 2020:
|
if int(i) + int(j) == 2020:
|
||||||
print("{} * {} == {}".format(int(i), int(j), int(i) * int(j)))
|
print("{} * {} = {}".format(int(i), int(j), int(i) * int(j)))
|
||||||
mustbreak = True
|
return
|
||||||
break
|
|
||||||
if mustbreak: break
|
def part2():
|
||||||
|
for i in lines:
|
||||||
|
for j in lines:
|
||||||
|
for k in lines:
|
||||||
|
if int(i) + int(j) + int(k) == 2020:
|
||||||
|
print("{} * {} * {} = {}".format(int(i), int(j), int(k), int(i) * int(j) * int(k)))
|
||||||
|
return
|
||||||
|
|
||||||
|
part1()
|
||||||
|
part2()
|
||||||
|
|
Loading…
Reference in New Issue