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