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
|
||||||
|
|
||||||
for i in lines:
|
def part1():
|
||||||
for j in lines:
|
for i in lines:
|
||||||
if int(i) + int(j) == 2020:
|
for j in lines:
|
||||||
print("{} * {} == {}".format(int(i), int(j), int(i) * int(j)))
|
if int(i) + int(j) == 2020:
|
||||||
mustbreak = True
|
print("{} * {} = {}".format(int(i), int(j), int(i) * int(j)))
|
||||||
break
|
return
|
||||||
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