Day 1 (glamorized)

This commit is contained in:
Sebastian Seedorf
2020-12-19 00:56:03 +01:00
parent af2e297a24
commit f6974a7ba3
2 changed files with 2 additions and 6 deletions

View File

@@ -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)

View File

@@ -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