mirror of
https://github.com/thib8956/advent-of-code.git
synced 2026-11-27 00:46:34 +00:00
fix lint
This commit is contained in:
1 parent
0232b9326d
commit
5c3fb89870
50 files changed
+97
-117
No files matched your search
@@ -27,12 +27,12 @@ def example(ingredients):
|
||||
# for example input, two ingredients such that
|
||||
# a + b = 100 with a and b >= 0
|
||||
max_score = 0
|
||||
for a in range(0, 101):
|
||||
for a in range(101):
|
||||
b = 100 - a
|
||||
# ignore last property (calories)
|
||||
qty_a = [x * a for x in ingredients[0][:-1]]
|
||||
qty_b = [x * b for x in ingredients[1][:-1]]
|
||||
props = [x + y if x + y > 0 else 0 for x, y in zip(qty_a, qty_b)]
|
||||
props = [max(0, x + y) for x, y in zip(qty_a, qty_b)]
|
||||
score = reduce(mul, props)
|
||||
max_score = max(score, max_score)
|
||||
return max_score
|
||||
@@ -40,14 +40,14 @@ def example(ingredients):
|
||||
|
||||
def example_part2(ingredients):
|
||||
max_score = 0
|
||||
for a in range(0, 101):
|
||||
for a in range(101):
|
||||
b = 100 - a
|
||||
qty_a = [x * a for x in ingredients[0]]
|
||||
qty_b = [x * b for x in ingredients[1]]
|
||||
# check calories == 500
|
||||
if qty_a[-1] + qty_b[-1] != 500:
|
||||
continue
|
||||
props = [x + y if x + y > 0 else 0 for x, y in zip(qty_a, qty_b)]
|
||||
props = [max(0, x + y) for x, y in zip(qty_a, qty_b)]
|
||||
score = reduce(mul, props[:-1])
|
||||
max_score = max(score, max_score)
|
||||
return max_score
|
||||
@@ -61,7 +61,7 @@ def part1(ingredients):
|
||||
qty_c = [x * c for x in ingredients[2][:-1]]
|
||||
qty_d = [x * d for x in ingredients[3][:-1]]
|
||||
props = [
|
||||
x + y + z + w if x + y + z + w > 0 else 0
|
||||
max(0, x + y + z + w)
|
||||
for x, y, z, w in zip(qty_a, qty_b, qty_c, qty_d)
|
||||
]
|
||||
score = reduce(mul, props)
|
||||
@@ -77,7 +77,7 @@ def part2(ingredients):
|
||||
qty_c = [x * c for x in ingredients[2]]
|
||||
qty_d = [x * d for x in ingredients[3]]
|
||||
props = [
|
||||
x + y + z + w if x + y + z + w > 0 else 0
|
||||
max(0, x + y + z + w)
|
||||
for x, y, z, w in zip(qty_a, qty_b, qty_c, qty_d)
|
||||
]
|
||||
# check calories == 500
|
||||
|
||||
Reference in new issue
Block a user