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