Day 2 completed
This commit is contained in:
37
day2/part2.py
Normal file
37
day2/part2.py
Normal file
@@ -0,0 +1,37 @@
|
||||
from common import parse
|
||||
|
||||
|
||||
def round(game: tuple[str, str]) -> int:
|
||||
if game[0] == "A":
|
||||
if game[1] == "X":
|
||||
return 3
|
||||
elif game[1] == "Y":
|
||||
return 3 + 1
|
||||
else:
|
||||
return 6 + 2
|
||||
elif game[0] == "B":
|
||||
if game[1] == "X":
|
||||
return 1
|
||||
elif game[1] == "Y":
|
||||
return 3 + 2
|
||||
else:
|
||||
return 6 + 3
|
||||
else:
|
||||
if game[1] == "X":
|
||||
return 2
|
||||
elif game[1] == "Y":
|
||||
return 3 + 3
|
||||
else:
|
||||
return 6 + 1
|
||||
|
||||
|
||||
def solve(strategy: list[tuple[str, str]]) -> int:
|
||||
return sum(map(round, strategy))
|
||||
|
||||
|
||||
def main():
|
||||
print(solve(parse("input")))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user