Advertisement
Guest User

04. Honey

a guest
Sep 24th, 2023
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.95 KB | None | 0 0
  1. from collections import deque
  2. working_bees = deque(int(x) for x in input().split())
  3. nectar_value = [int(x) for x in input().split()]
  4. symbols = deque(input().split())
  5.  
  6. dict_symbols = {
  7.     "*": lambda a, b: a * b,
  8.     "/": lambda a, b: a / b,
  9.     "+": lambda a, b: a + b,
  10.     "-": lambda a, b: a - b,
  11. }
  12.  
  13. honey_made = 0
  14. while nectar_value and working_bees:
  15.     if working_bees[0] > nectar_value[-1]:
  16.         nectar_value.pop()
  17.     else:
  18.         current_symbol = symbols.popleft()
  19.         if current_symbol == '/' and nectar_value[-1] == 0:
  20.             working_bees.popleft()
  21.             nectar_value.pop()
  22.             symbols.popleft()
  23.         honey_made += abs(dict_symbols[current_symbol](working_bees.popleft(), nectar_value.pop()))
  24.  
  25. print(f"Total honey made: {honey_made}")
  26.  
  27. if working_bees:
  28.     print(f"Bees left: {', '.join(str(x) for x in working_bees)}")
  29. if nectar_value:
  30.     print(f"Nectar left: {', '.join(str(x) for x in nectar_value)}")
  31.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement