Advertisement
GalinaKG

Advent of code - Day 2 - First task

Dec 2nd, 2022
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.71 KB | None | 0 0
  1. my_sum = 0
  2.  
  3. #  Elf -> A - Rock, B - Peper, C - Scissor
  4.  
  5. with open("input_data.txt", "r") as file:
  6.     for line in file.readlines():
  7.  
  8.         if line[2] == 'Y':   # rock
  9.             my_sum += 2
  10.             if line[0] == 'A':
  11.                 my_sum += 6
  12.             elif line[0] == 'B':
  13.                 my_sum += 3
  14.  
  15.         elif line[2] == 'X':  # peper
  16.             my_sum += 1
  17.             if line[0] == 'C':
  18.                 my_sum += 6
  19.             elif line[0] == 'A':
  20.                 my_sum += 3
  21.  
  22.         elif line[2] == 'Z':   # scissor
  23.             my_sum += 3
  24.             if line[0] == 'C':
  25.                 my_sum += 3
  26.             elif line[0] == 'B':
  27.                 my_sum += 6
  28.  
  29. print(my_sum)
  30.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement