Advertisement
Guest User

Untitled

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