Compare commits

..

1 commit

Author SHA1 Message Date
d42ae1226d Solve 2022:1 pt 1-2 2025-11-15 15:05:09 +01:00
2 changed files with 41 additions and 31 deletions

View file

@ -1,4 +1,9 @@
from output import ints
import re
from collections import deque, Counter, defaultdict
from heapq import heappop, heappush
from itertools import compress, combinations, chain, permutations
from output import matrix, D, DD, ADJ, ints, mhd, mdbg, vdbg, cw, ccw, bk
def solve(data):
@ -14,6 +19,8 @@ def solve(data):
if __name__ == "__main__":
import os
with open("./input/01.txt", "r") as f:
inp = f.read().strip()

View file

@ -1,40 +1,43 @@
import re
from collections import deque, Counter, defaultdict
from heapq import heappop, heappush
from itertools import compress, combinations, chain, permutations
from output import matrix, D, DD, ADJ, ints, mhd, mdbg, vdbg, cw, ccw, bk
def solve(data):
S1 = {
"A X": 1 + 3,
"A Y": 2 + 6,
"A Z": 3 + 0,
"B X": 1 + 0,
"B Y": 2 + 3,
"B Z": 3 + 6,
"C X": 1 + 6,
"C Y": 2 + 0,
"C Z": 3 + 3,
}
S2 = {
"A X": 3 + 0,
"A Y": 1 + 3,
"A Z": 2 + 6,
"B X": 1 + 0,
"B Y": 2 + 3,
"B Z": 3 + 6,
"C X": 2 + 0,
"C Y": 3 + 3,
"C Z": 1 + 6,
}
R = data.splitlines()
p1 = sum(S1[r] for r in R)
p2 = sum(S2[r] for r in R)
p1 = None
p2 = None
return p1, p2
if __name__ == "__main__":
with open("./input/02.txt", "r") as f:
inp = f.read().strip()
import os
# use dummy data
inp = """
A Y
B X
C Z
""".strip()
# uncomment to instead use stdin
# import sys; inp = sys.stdin.read().strip()
# uncomment to use AoC provided puzzle input
# with open("./input/02.txt", "r") as f:
# inp = f.read().strip()
# uncomment to do initial data processing shared by part 1-2
p1, p2 = solve(inp)
print(p1)
print(p2)
os.system(f"echo {p1} | wl-copy")
# print(p2)
# os.system(f"echo {p2} | wl-copy")
assert p1 == 12772
assert p2 == 11618
# uncomment and replace 0 with actual output to refactor code
# and ensure nonbreaking changes
# assert p1 == 0
# assert p2 == 0