Fix black

This commit is contained in:
Gabriel Augendre 2022-12-03 22:30:29 +01:00
parent b5a01d5afb
commit c04ee4c040

View file

@ -43,7 +43,9 @@ def solve_part_1(data: DataType) -> int:
def solve_part_2(data: list[str]) -> int: def solve_part_2(data: list[str]) -> int:
total = 0 total = 0
for chunk in chunks(data, 3): for chunk in chunks(data, 3):
common_letter = set(chunk[0]).intersection(set(chunk[1])).intersection(set(chunk[2])).pop() common_letter = (
set(chunk[0]).intersection(set(chunk[1])).intersection(set(chunk[2])).pop()
)
total += string.ascii_letters.index(common_letter) + 1 total += string.ascii_letters.index(common_letter) + 1
return total return total
@ -52,6 +54,7 @@ def chunks(data, size):
for i in range(0, len(data), size): for i in range(0, len(data), size):
yield data[i : i + size] yield data[i : i + size]
if __name__ == "__main__": if __name__ == "__main__":
main("inputs/day03-test1", expected_part_1=157, expected_part_2=70) main("inputs/day03-test1", expected_part_1=157, expected_part_2=70)
main("inputs/day03", expected_part_1=7716, expected_part_2=2973) main("inputs/day03", expected_part_1=7716, expected_part_2=2973)