Advertisement
Spocoman

Suitcases Load

Mar 15th, 2022 (edited)
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.38 KB | None | 0 0
  1. capacity = float(input())
  2. counter = 1
  3.  
  4. while True:
  5.     suitcase = input()
  6.     if suitcase == "End":
  7.         print("Congratulations! All suitcases are loaded!")
  8.         break
  9.     box = float(suitcase)
  10.     if counter % 3 == 0:
  11.         box *= 1.1
  12.     if box > capacity:
  13.         print("No more space!")
  14.         break
  15.     capacity -= box
  16.     counter += 1
  17.  
  18. print(f"Statistic: {counter - 1} suitcases loaded.")
  19.  
  20.  
  21. РЕШЕНИЕ С FOR:
  22.  
  23. import sys
  24.  
  25. capacity = float(input())
  26.  
  27. for i in range(1, sys.maxsize):
  28.     suitcase = input()
  29.     if suitcase == "End":
  30.         print("Congratulations! All suitcases are loaded!")
  31.         print(f"Statistic: {i - 1} suitcases loaded.")
  32.         break
  33.     box = float(suitcase)
  34.     if i % 3 == 0:
  35.         box *= 1.1
  36.     if box > capacity:
  37.         print(f"No more space!\nStatistic: {i - 1} suitcases loaded.")
  38.         break
  39.     capacity -= box
  40.  
  41.  
  42. РЕШЕНИЕ С ТЕРНАРЕН ОПЕРАТОР ЛЕКО ТАРИКАТСКАТА:
  43.  
  44. import sys
  45.  
  46. capacity = float(input())
  47.  
  48. for i in range(1, sys.maxsize):
  49.     suitcase = input()
  50.     if suitcase != "End":
  51.         capacity -= float(suitcase) * (1.1 if i % 3 == 0 else 1)      
  52.     if capacity < 0 or suitcase == "End":
  53.         print(f"No more space!" if capacity < 0 else "Congratulations! All suitcases are loaded!")
  54.         print(f"Statistic: {i - 1} suitcases loaded.")
  55.         break
  56.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement