Skip to content

Instantly share code, notes, and snippets.

@felipedavi
Created December 25, 2022 03:49
Show Gist options
  • Save felipedavi/25c21182fe76e1a000dd554cc864bd87 to your computer and use it in GitHub Desktop.
Save felipedavi/25c21182fe76e1a000dd554cc864bd87 to your computer and use it in GitHub Desktop.
Day2 Try Aoc 2022
#coding: utf-8
score = int(0)
pointsh={"Rock":1, "Paper":2, "Scissors":3}
points={"Winner":6, "Draw":3, "Loser":0}
file = open("dataday.txt", "r")
for line in file:
if line in ['\n', '\r\n']:
pass
else:
tmp = line.split(' ')
n = tmp[0]
m = tmp[1].replace('\n', '')
if n == 'A' and m == 'X':
score+=(points['Loser']+pointsh['Scissors'])
if n == 'A' and m == 'Y':
score+=(points['Draw']+pointsh['Rock'])
if n == 'A' and m == 'Z':
score+=(points['Winner']+pointsh['Paper'])
if n == 'B' and m == 'X':
score+=(points['Loser']+pointsh['Scissors'])
if n == 'B' and m == 'Y':
score+=(points['Draw']+pointsh['Paper'])
if n == 'B' and m == 'Z':
score+=(points['Winner']+pointsh['Rock'])
if n == 'C' and m == 'X':
score+=(points['Loser']+pointsh['Rock'])
if n == 'C' and m == 'Y':
score+=(points['Draw']+pointsh['Scissors'])
if n == 'C' and m == 'Z':
score+=(points['Winner']+pointsh['Rock'])
print("Score: " + str(score))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment