Advertisement
Nenogzar

01_pizza_orders

Jun 5th, 2024
373
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.86 KB | None | 0 0
  1. from collections import deque
  2. pizza_orders = deque(int(x) for x in input().split(", ") if 0 < int(x) <= 10)   #  COOOOOOL  :)
  3. employees = deque(int(x) for x in input().split(", "))
  4.  
  5. total_pizzas = 0
  6.  
  7. while pizza_orders and employees:
  8.     current_order = pizza_orders.popleft()
  9.     employee_capacity = employees.pop()
  10.  
  11.     if current_order > employee_capacity:
  12.         current_order -= employee_capacity
  13.         total_pizzas += employee_capacity
  14.         pizza_orders.appendleft(current_order)
  15.         continue
  16.  
  17.     total_pizzas += current_order
  18. if not pizza_orders:
  19.     print(f"""
  20.    All orders are successfully completed!
  21.    Total pizzas made: {total_pizzas}
  22.    Employees: {', '.join(str(x) for x in employees)}
  23. """)
  24. elif pizza_orders:
  25.     print(f"""
  26.    Not all orders are completed.
  27.    Orders left: {', '.join(str(x) for x in pizza_orders)}
  28. """)
  29.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement