Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from collections import deque
- chocolates_stack = [int(n) for n in input().split(', ')]
- milk_cups = deque([int(n) for n in input().split(', ')])
- milkshakes = 0
- while milkshakes < 5 and chocolates_stack and milk_cups:
- current_chocolate = chocolates_stack[-1]
- current_milkcup = milk_cups[0]
- if current_chocolate <= 0 and current_milkcup <= 0:
- chocolates_stack.pop()
- milk_cups.popleft()
- continue
- elif current_milkcup <= 0:
- milk_cups.popleft()
- continue
- elif current_chocolate <= 0:
- chocolates_stack.pop()
- continue
- if current_milkcup == current_chocolate:
- milkshakes += 1
- chocolates_stack.pop()
- milk_cups.popleft()
- else:
- milk_cups.append(milk_cups.popleft())
- chocolates_stack[-1] -= 5
- if milkshakes >= 5:
- print("Great! You made all the chocolate milkshakes needed!")
- else:
- print("Not enough milkshakes.")
- if chocolates_stack:
- print(f"Chocolate: {', '.join([str(n) for n in chocolates_stack])}")
- else:
- print("Chocolate: empty")
- if milk_cups:
- print(f"Milk: {', '.join([str(n) for n in milk_cups])}")
- else:
- print("Milk: empty")
Advertisement
Add Comment
Please, Sign In to add comment