Day 1 (glamorized)
This commit is contained in:
@@ -5,6 +5,6 @@ done = set()
|
||||
for item in items:
|
||||
counterpart = 2020 - item
|
||||
if counterpart in done:
|
||||
print("Found {} and {}: Sum={} Product={}".format(item, counterpart, item+counterpart, item*counterpart))
|
||||
print(item*counterpart)
|
||||
break
|
||||
done.add(item)
|
||||
|
||||
@@ -22,11 +22,7 @@ for item in items:
|
||||
new = (elem[0] - item, elem[1]-1)
|
||||
if new == (0, 0):
|
||||
vals = tree_up(item)
|
||||
print("Found [{}]: Sum={}, Product={}".format(
|
||||
", ".join(map(str, vals)),
|
||||
sum(vals),
|
||||
prod(vals)
|
||||
))
|
||||
print(prod(vals))
|
||||
elif new[0] > 0 and new[1] > 0:
|
||||
if new not in tree:
|
||||
tree[new] = item
|
||||
|
||||
Reference in New Issue
Block a user