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