Advertisement
bl00dt3ars

04. Darts

Nov 6th, 2020 (edited)
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.98 KB | None | 0 0
  1. name = input()
  2. total_points = 301
  3. total_shots = 0
  4. successful_shots = 0
  5.  
  6. sector = input()
  7.  
  8. while sector != "Retire":
  9.     current_points = int(input())
  10.     total_shots += 1
  11.     if sector == "Single":
  12.         total_points -= current_points
  13.         if total_points >= 0:
  14.             successful_shots += 1
  15.         else:
  16.             total_points += current_points
  17.     elif sector == "Double":
  18.         total_points -= current_points * 2
  19.         if total_points >= 0:
  20.             successful_shots += 1
  21.         else:
  22.             total_points += current_points * 2
  23.     else:
  24.         total_points -= current_points * 3
  25.         if total_points >= 0:
  26.             successful_shots += 1
  27.         else:
  28.             total_points += current_points * 3
  29.     if total_points == 0:
  30.         break
  31.     sector = input()
  32.    
  33. if total_points == 0:
  34.     print(f"{name} won the leg with {successful_shots} shots.")
  35. else:
  36.     print(f"{name} retired after {total_shots - successful_shots} unsuccessful shots.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement