Compare commits

..

2 commits

2 changed files with 31 additions and 41 deletions

View file

@ -1,9 +1,4 @@
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
from output import ints
def solve(data):
@ -19,8 +14,6 @@ def solve(data):
if __name__ == "__main__":
import os
with open("./input/01.txt", "r") as f:
inp = f.read().strip()

View file

@ -1,43 +1,40 @@
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):
p1 = None
p2 = None
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)
return p1, p2
if __name__ == "__main__":
import os
with open("./input/02.txt", "r") as f:
inp = f.read().strip()
# 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)
os.system(f"echo {p1} | wl-copy")
# print(p2)
# os.system(f"echo {p2} | wl-copy")
print(p2)
# uncomment and replace 0 with actual output to refactor code
# and ensure nonbreaking changes
# assert p1 == 0
# assert p2 == 0
assert p1 == 12772
assert p2 == 11618