Refactoring solution for problem 2

This commit is contained in:
David Doblas Jiménez 2022-02-20 20:46:13 +01:00
parent 53c9e39071
commit 5954c07891

View File

@ -80,13 +80,13 @@ def part_2() -> None:
result = []
for row in int_spreadsheet:
pairs = combinations(row, 2)
for el1, el2 in pairs:
if el1 % el2 == 0:
result.append(int(el1 / el2))
break
elif el2 % el1 == 0:
result.append(int(el2 / el1))
for els in pairs:
if max(els) % min(els) == 0:
result.append(int(max(els) / min(els)))
break
# elif el2 % el1 == 0:
# result.append(int(el2 / el1))
# break
print(f"Sum of each row's result is {sum(result)}")