Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #/usr/bin/env python3
- score=0
- win=['B Z','C X','A Y']
- draw=['A X','B Y','C Z']
- with open("input.txt") as file:
- for line in file:
- line=line.strip()
- if line in draw:
- score += ((ord(line.split()[1])-87)+3) #ord('X')=88
- elif line in win:
- score += ((ord(line.split()[1])-87)+6)
- else:
- score += (ord(line.split()[1])-87)
- print("Part one: ", score)
- ###############################################################################################
- score=0
- lost=['Z', 'X', 'Y']
- win=['Y', 'Z', 'X']
- draw=['X','Y','Z']
- with open("input.txt") as file:
- for line in file:
- text=line.split()
- index=(ord(text[0])-65) #A - index 0; B - 1; C - 2
- if text[1]=='X':
- score += (ord(lost[index])-87)
- elif text[1]=='Y':
- score += ((ord(draw[index])-87)+3)
- elif text[1]=='Z':
- score += ((ord(win[index])-87)+6)
- print("Part two:", score)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement