day02
This commit is contained in:
parent
e268462b65
commit
121e71a088
46
day02.py
Normal file
46
day02.py
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
from tools.aoc import AOCDay
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
|
|
||||||
|
class Day(AOCDay):
|
||||||
|
inputs = [
|
||||||
|
[
|
||||||
|
(15, "input2_test"),
|
||||||
|
(14163, "input2"),
|
||||||
|
],
|
||||||
|
[
|
||||||
|
(12, "input2_test"),
|
||||||
|
(12091, "input2"),
|
||||||
|
]
|
||||||
|
]
|
||||||
|
|
||||||
|
def part1(self) -> Any:
|
||||||
|
score = 0
|
||||||
|
for line in self.getInput():
|
||||||
|
e, m = map(ord, line.split(" "))
|
||||||
|
e, m = e - 64, m - 64 - 23
|
||||||
|
score += m
|
||||||
|
if e == m:
|
||||||
|
score += 3
|
||||||
|
elif m == e + 1 or m == (e + 1) % 3:
|
||||||
|
score += 6
|
||||||
|
|
||||||
|
return score
|
||||||
|
|
||||||
|
def part2(self) -> Any:
|
||||||
|
score = 0
|
||||||
|
for line in self.getInput():
|
||||||
|
e, m = map(ord, line.split(" "))
|
||||||
|
e -= 64
|
||||||
|
if m == 88: # lose!
|
||||||
|
score += 3 if e == 1 else e - 1
|
||||||
|
elif m == 89: # draw!
|
||||||
|
score += 3 + e
|
||||||
|
else: # win!
|
||||||
|
score += 7 if e == 3 else e + 7
|
||||||
|
return score
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
day = Day(2022, 2)
|
||||||
|
day.run(verbose=True)
|
||||||
2500
inputs/input2
Normal file
2500
inputs/input2
Normal file
File diff suppressed because it is too large
Load Diff
3
inputs/input2_test
Normal file
3
inputs/input2_test
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
A Y
|
||||||
|
B X
|
||||||
|
C Z
|
||||||
Loading…
Reference in New Issue
Block a user