| 
				
			 | 
			
			 | 
			@@ -0,0 +1,53 @@ | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			# https://adventofcode.com/2022/day/2 | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			
  | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			MOVE_SCORES = { | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			    "A": 1, | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			    "B": 2, | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			    "C": 3, | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			    "X": 0, | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			    "Y": 3, | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			    "Z": 6 | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			} | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			
  | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			MOVE_BEATS = { | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			    "A": "C", | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			    "B": "A", | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			    "C": "B" | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			} | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			
  | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			MOVE_LOSES = { | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			    "A": "B", | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			    "B": "C", | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			    "C": "A" | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			} | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			
  | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			def main(): | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			    with open("input2.txt", "r") as file: | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			        moves = [line.strip() for line in file.readlines()] | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			
  | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			    # moves = [(x, y) for line in inlines for x, y in line.split(" ")] | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			
  | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			    scores = [] | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			    for move in moves: | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			        (theirs, mine) = move.split(" ") | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			        cur_score = MOVE_SCORES[mine] | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			
  | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			        if mine == "X": | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			            # Have to lose. | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			            # Add the score of the move that their move beats. | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			            cur_score += MOVE_SCORES[MOVE_BEATS[theirs]] | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			        elif mine == "Y": | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			            # Have to tie. | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			            # Add the score of the move that they made. | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			            cur_score += MOVE_SCORES[theirs] | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			        elif mine == "Z": | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			            # Have to win. | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			            # Add the score of the move that theirs loses to. | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			            cur_score += MOVE_SCORES[MOVE_LOSES[theirs]] | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			             | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			        scores.append(cur_score) | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			
  | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			    print(sum(scores)) | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			
  | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			if __name__ == "__main__": | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			    main() |