Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from collections import deque
- chocolates = [int(el) for el in input().split(",")]
- cups_of_milk = deque([int(el) for el in input().split(",")])
- chocolate_milkshakes = 0
- enough_chocolate_milkshakes = False
- while True:
- if chocolate_milkshakes >= 5:
- enough_chocolate_milkshakes = True
- break
- if len(chocolates) <= 0 or len(cups_of_milk) <= 0:
- break
- last_chocolate = chocolates[-1]
- first_cup_of_milk = cups_of_milk[0]
- if last_chocolate <= 0 or first_cup_of_milk <= 0:
- if last_chocolate <= 0:
- chocolates.pop()
- else:
- cups_of_milk.popleft()
- continue
- if last_chocolate == first_cup_of_milk:
- chocolate_milkshakes += 1
- chocolates.pop()
- cups_of_milk.popleft()
- else:
- cups_of_milk.append(cups_of_milk.popleft())
- chocolates[-1] -= 5
- if enough_chocolate_milkshakes:
- print("Great! You made all the chocolate milkshakes needed!")
- else:
- print("Not enough milkshakes.")
- if chocolates:
- print(f"Chocolate: {', '.join([str(el) for el in chocolates])}")
- else:
- print("Chocolate: empty")
- if cups_of_milk:
- print(f"Milk: {', '.join([str(el) for el in cups_of_milk])}")
- else:
- print("Milk: empty")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement