Refactoring solution for problem 2
This commit is contained in:
@@ -80,13 +80,13 @@ def part_2() -> None:
|
|||||||
result = []
|
result = []
|
||||||
for row in int_spreadsheet:
|
for row in int_spreadsheet:
|
||||||
pairs = combinations(row, 2)
|
pairs = combinations(row, 2)
|
||||||
for el1, el2 in pairs:
|
for els in pairs:
|
||||||
if el1 % el2 == 0:
|
if max(els) % min(els) == 0:
|
||||||
result.append(int(el1 / el2))
|
result.append(int(max(els) / min(els)))
|
||||||
break
|
|
||||||
elif el2 % el1 == 0:
|
|
||||||
result.append(int(el2 / el1))
|
|
||||||
break
|
break
|
||||||
|
# elif el2 % el1 == 0:
|
||||||
|
# result.append(int(el2 / el1))
|
||||||
|
# break
|
||||||
|
|
||||||
print(f"Sum of each row's result is {sum(result)}")
|
print(f"Sum of each row's result is {sum(result)}")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user