Advertisement
Monstera

matura 2022 grudzień

Apr 13th, 2023
577
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.01 KB | None | 0 0
  1. mecz = 'mecz.txt'
  2. mecz_test = "mecz_przyklad.txt"
  3.  
  4. with open(mecz) as file:
  5.     line = file.readline()
  6.  
  7. # 1.1
  8.     count = 0
  9.  
  10.     for i in range(1, len(line) - 1):
  11.         if str(line[i]) != str(line[i-1]):
  12.             count = count + 1
  13.  
  14.     print(count)
  15.  
  16. # 1.2
  17.     a = 0
  18.     b = 0
  19.  
  20.     for i in range(len(line) - 1):
  21.         if line[i] == 'A':
  22.             a = a + 1
  23.  
  24.         if line[i] == 'B':
  25.             b = b + 1
  26.  
  27.         if (a >= 1000 or b >= 1000) and (abs(a - b) >= 3):
  28.             print (f'{a}:{b}')
  29.             break
  30.  
  31. # 1.3
  32.     streak_team = ''
  33.     w = 1
  34.  
  35.     streaks = []
  36.  
  37.  
  38.  
  39.     for i in range(1, len(line) - 1):
  40.         if line[i - 1] == line[i]:
  41.             w = w + 1
  42.  
  43.         else:
  44.             if w >= 10:
  45.                 well_streak = {}
  46.                 well_streak["team"] = line[i - 1]
  47.                 well_streak["streak"] = w
  48.                 streaks.append(well_streak)
  49.  
  50.             w = 1
  51.  
  52. # get the max of ['streak'] and show it and the 'team' which make this score
  53.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement