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