Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from collections import deque
- def if_chocolates_left(chocolate: list):
- if len(chocolate) > 0:
- return f"Chocolate: {', '.join([str(i) for i in chocolate])}"
- else:
- return "Chocolate: empty"
- def if_cups_milk_left(milk):
- if len(milk) > 0:
- return f"Milk: {', '.join([str(i) for i in milk])}"
- else:
- return "Milk: empty"
- chocolates = [int(x) for x in input().split(", ")]
- cups__milk = [int(x) for x in input().split(", ")]
- chocolate_stack = []
- cups_milk_queue = deque(cups__milk)
- for i in chocolates:
- chocolate_stack.append(i)
- counter = 0
- while True:
- if counter == 5:
- break
- if len(cups_milk_queue) > 0 and len(chocolate_stack) > 0:
- current_chocolate = chocolate_stack.pop()
- current_cup_milk = cups_milk_queue.popleft()
- if current_chocolate > 0 and current_cup_milk > 0:
- if current_chocolate == current_cup_milk:
- counter += 1
- else:
- cups_milk_queue.append(current_cup_milk)
- current_chocolate -= 5
- if current_chocolate > 0:
- chocolate_stack.append(current_chocolate)
- else:
- if current_chocolate < 0:
- cups_milk_queue.appendleft(current_cup_milk)
- elif current_cup_milk < 0:
- chocolate_stack.append(current_chocolate)
- else:
- break
- if counter == 5:
- print(f"Great! You made all the chocolate milkshakes needed!")
- else:
- print(f"Not enough milkshakes.")
- print(if_chocolates_left(chocolate_stack))
- print(if_cups_milk_left(cups_milk_queue))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement