Spocoman

Darts

Feb 13th, 2022 (edited)
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.66 KB | None | 0 0
  1. name = input()
  2. zone = input()
  3. count_yes = 0
  4. count_no = 0
  5. total = 301
  6.  
  7. while zone != "Retire":
  8.     dots = int(input())
  9.     if zone == "Double":
  10.         dots *= 2
  11.     elif zone == "Triple":
  12.         dots *= 3
  13.        
  14.     if total < dots:
  15.         count_no += 1
  16.     else:
  17.         total -= dots
  18.         count_yes += 1
  19.        
  20.     if total == 0:
  21.         break
  22.     zone = input()
  23.  
  24. if total == 0:
  25.     print(f"{name} won the leg with {count_yes} shots.")
  26. else:
  27.     print(f"{name} retired after {count_no} unsuccessful shots.")
  28.    
  29.  
  30. РЕШЕНИЕ С ТЕРНАРЕН ОПЕРАТОР:
  31.  
  32. name = input()
  33. zone = input()
  34. count_yes = 0
  35. count_no = 0
  36. total = 301
  37.  
  38. while zone != "Retire":
  39.     dots = int(input()) * (2 if zone == "Double" else 3 if zone == "Triple" else 1)
  40.     count_yes += 1 if total >= dots else 0
  41.     count_no += 1 if total < dots else 0
  42.     total -= dots if total >= dots else 0
  43.  
  44.     if total == 0:
  45.         break
  46.     zone = input()
  47.  
  48. print(f"{name} won the leg with {count_yes} shots." if total == 0
  49.       else f"{name} retired after {count_no} unsuccessful shots.")
  50.  
  51.  
  52. РЕШЕНИЕ С КОЛЕКЦИЯ И ТЕРНАРЕН ОПЕРАТОР:
  53.  
  54. name = input()
  55. zone = input()
  56. count_yes = 0
  57. count_no = 0
  58. total = 301
  59.  
  60. while zone != "Retire":
  61.     dots = int(input()) * {"Single": 1, "Double": 2, "Triple": 3}[zone]
  62.    count_yes += 1 if total >= dots else 0
  63.     count_no += 1 if total < dots else 0
  64.     total -= dots if total >= dots else 0
  65.  
  66.     if total == 0:
  67.         break
  68.     zone = input()
  69.  
  70. print(f"{name} won the leg with {count_yes} shots." if total == 0
  71.       else f"{name} retired after {count_no} unsuccessful shots.")
  72.  
Add Comment
Please, Sign In to add comment