Advertisement
viligen

milkshakes

Jan 19th, 2022
634
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. from collections import deque
  2.  
  3. chocolates_stack = [int(n) for n in input().split(', ')]
  4. milk_cups = deque([int(n) for n in input().split(', ')])
  5.  
  6. milkshakes = 0
  7.  
  8. while milkshakes < 5 and chocolates_stack and milk_cups:
  9.  
  10.     current_chocolate = chocolates_stack[-1]
  11.     current_milkcup = milk_cups[0]
  12.  
  13.     if current_chocolate <= 0 and current_milkcup <= 0:
  14.         chocolates_stack.pop()
  15.         milk_cups.popleft()
  16.         continue
  17.     elif current_milkcup <= 0:
  18.         milk_cups.popleft()
  19.         continue
  20.     elif current_chocolate <= 0:
  21.         chocolates_stack.pop()
  22.         continue
  23.     if current_milkcup == current_chocolate:
  24.         milkshakes += 1
  25.         chocolates_stack.pop()
  26.         milk_cups.popleft()
  27.     else:
  28.         milk_cups.append(milk_cups.popleft())
  29.         chocolates_stack[-1] -= 5
  30.  
  31. if milkshakes >= 5:
  32.     print("Great! You made all the chocolate milkshakes needed!")
  33. else:
  34.     print("Not enough milkshakes.")
  35.  
  36. if chocolates_stack:
  37.     print(f"Chocolate: {', '.join([str(n) for n in chocolates_stack])}")
  38. else:
  39.     print("Chocolate: empty")
  40.  
  41. if milk_cups:
  42.     print(f"Milk: {', '.join([str(n) for n in milk_cups])}")
  43. else:
  44.     print("Milk: empty")
  45.  
  46.  
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement