Advertisement
go6odn28

honey_2

May 20th, 2024
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.83 KB | None | 0 0
  1. from collections import deque
  2.  
  3. bees = deque(map(int, input().split()))
  4. nectar = list(map(int, input().split()))
  5.  
  6. symbols = input().split()
  7. symbols = symbols[::-1]
  8.  
  9. operations = {
  10.     "*": lambda b, n: b * n,
  11.     "/": lambda b, n: b / n,
  12.     "-": lambda b, n: b - n,
  13.     "+": lambda b, n: b + n
  14. }
  15. totalhoney = 0
  16. honey = 0
  17.  
  18. while bees and nectar:
  19.     bee = bees.popleft()
  20.     nect = nectar.pop()
  21.  
  22.     if bee > nect:
  23.         bees.appendleft(bee)
  24.  
  25.     elif nect >= bee:
  26.         symbol = symbols.pop()
  27.         if nect == 0 and symbol == "/":
  28.             continue
  29.         honey = operations[symbol](bee, nect)
  30.         totalhoney += abs(honey)
  31.  
  32.  
  33. print("Total honey made:", totalhoney)
  34.  
  35. if bees: print(f"Bees left: {', '.join([str(x) for x in bees])}")
  36. if nectar: print(f"Nectar left: {', '.join([str(x) for x in nectar])}")
  37.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement