Advertisement
horozov86

milkshakes

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