Advertisement
go6odn28

4_honey

May 20th, 2024
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.80 KB | None | 0 0
  1. from collections import deque
  2.  
  3. working_bees = deque(map(int, input().split()))
  4. nectars = list(map(int, input().split()))
  5. symbols = deque(input().split())
  6. total_honey = 0
  7.  
  8. while working_bees and nectars:
  9.     bee = working_bees.popleft()
  10.     nectar = nectars.pop()
  11.  
  12.     if bee > nectar:
  13.         working_bees.appendleft(bee)
  14.  
  15.     elif bee <= nectar:
  16.         curr_symbol = symbols.popleft()
  17.         if curr_symbol == "/" and nectar == 0:
  18.             continue
  19.  
  20.         else:
  21.             expression = f"{bee} {curr_symbol} {nectar}"
  22.             result = abs(eval(expression))
  23.             total_honey += result
  24.  
  25. print(f"Total honey made: {total_honey}")
  26.  
  27. if working_bees:
  28.     print(f"Bees left: {', '.join(map(str, working_bees))}")
  29. if nectars:
  30.     print(f"Nectar left: {', '.join(map(str, nectars))}")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement