Refactoring solution for problem 2
This commit is contained in:
parent
53c9e39071
commit
5954c07891
@ -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)}")
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user