Move Python solutions

This commit is contained in:
Felix Bargfeldt 2023-10-19 22:06:58 +02:00
parent 6fae773051
commit 2f1872bbd9
Signed by: Defelo
GPG key ID: 2A05272471204DD3
255 changed files with 0 additions and 4323 deletions

19
Python/2022/03.py Normal file
View file

@ -0,0 +1,19 @@
def part1(puzzle: str):
return sum(
ord((x := ({*line[: len(line) // 2]} & {*line[len(line) // 2 :]}).pop()).upper()) - 64 + 26 * x.isupper()
for line in puzzle.splitlines()
)
def part2(puzzle: str):
lines = puzzle.splitlines()
return sum(
ord((x := ({*lines[i]} & {*lines[i + 1]} & {*lines[i + 2]}).pop()).upper()) - 64 + 26 * x.isupper()
for i in range(0, len(lines), 3)
)
if __name__ == "__main__":
from aoc import run
run(2022, 3, part1, part2)