Advertisement
rolfvanoven

AoC 2022 dag 2

Dec 2nd, 2022
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.09 KB | None | 0 0
  1. bestand = open('input.txt', 'r')
  2. alles = bestand.readlines()
  3.  
  4. score = 0
  5.  
  6. for x in range(len(alles)):
  7.   if alles[x][2] == 'X':
  8.     score += 1
  9.     if alles[x][0] == 'A':
  10.       score += 3
  11.     if alles[x][0] == 'C':
  12.       score += 6
  13.   elif alles[x][2] == 'Y':
  14.     score += 2
  15.     if alles[x][0] == 'A':
  16.       score += 6
  17.     if alles[x][0] == 'B':
  18.       score += 3
  19.   elif alles[x][2] == 'Z':
  20.     score += 3
  21.     if alles[x][0] == 'B':
  22.       score += 6
  23.     if alles[x][0] == 'C':
  24.       score += 3
  25. print(score)
  26.  
  27. score = 0
  28.  
  29. for x in range(len(alles)):
  30.   if alles[x][2] == 'X':
  31.     if alles[x][0] == 'A':
  32.       score += 3
  33.     if alles[x][0] == 'B':
  34.       score += 1
  35.     if alles[x][0] == 'C':
  36.       score += 2
  37.   elif alles[x][2] == 'Y':
  38.     score += 3
  39.     if alles[x][0] == 'A':
  40.       score += 1
  41.     if alles[x][0] == 'B':
  42.       score += 2
  43.     if alles[x][0] == 'C':
  44.       score += 3
  45.   elif alles[x][2] == 'Z':
  46.     score += 6
  47.     if alles[x][0] == 'A':
  48.       score += 2
  49.     if alles[x][0] == 'B':
  50.       score += 3
  51.     if alles[x][0] == 'C':
  52.       score += 1
  53.  
  54. print(score)
  55.  
  56.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement