Advertisement
go6odn28

milkshakes

May 20th, 2024
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.87 KB | None | 0 0
  1. from collections import deque
  2.  
  3. chocs = [int(x) for x in input().split(", ")]
  4. milks = deque([int(x) for x in input().split(", ")])
  5.  
  6. shakes = 0
  7.  
  8. while milks and chocs:
  9.     if shakes == 5:
  10.         break
  11.     choc = chocs.pop()
  12.     milk = milks.popleft()
  13.  
  14.     if milk <= 0 and choc <= 0:
  15.         continue
  16.     if choc <= 0:
  17.         milks.appendleft(milk)
  18.         continue
  19.     if milk <= 0:
  20.         chocs.append(choc)
  21.         continue
  22.     elif choc == milk:
  23.         shakes += 1
  24.     else:
  25.         milks.append(milk)
  26.         choc -= 5
  27.         chocs.append(choc)
  28.  
  29. print("Great! You made all the chocolate milkshakes needed!") if shakes == 5 else print("Not enough milkshakes.")
  30. print(f"Chocolate: {', '.join([str(x) for x in chocs])}") if chocs else print("Chocolate: empty")
  31. print(f"Milk: {', '.join([str(x) for x in milks])}") if milks else print("Milk: empty")
  32.  
  33.  
  34.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement