sibinasto

01. Bee

Aug 18th, 2021
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.20 KB | None | 0 0
  1. from collections import deque
  2.  
  3. working_bees = deque([int(n) for n in input().split()])
  4. amount_of_nectar = deque([int(n) for n in input().split()])
  5. symbols = deque([n for n in input().split()])
  6. total_honey_made = 0
  7.  
  8. while working_bees and amount_of_nectar:
  9.     first_bee = working_bees.popleft()
  10.     first_nectar = amount_of_nectar.pop()
  11.     if first_nectar < first_bee:
  12.         working_bees.appendleft(first_bee)
  13.         continue
  14.     elif first_nectar >= first_bee:
  15.         first_symbol = symbols.popleft()
  16.         if first_symbol == "+":
  17.             total_honey_made += abs(first_bee + first_nectar)
  18.         elif first_symbol == "-":
  19.             total_honey_made += abs(first_bee - first_nectar)
  20.         elif first_symbol == "*":
  21.             total_honey_made += abs(first_bee * first_nectar)
  22.         elif first_symbol == "/":
  23.             if first_nectar != 0:
  24.                 total_honey_made += abs(first_bee / first_nectar)
  25.             continue
  26.         continue
  27.  
  28. print(f"Total honey made: {total_honey_made}")
  29. if working_bees:
  30.     print(f"Bees left: {', '.join(str(x) for x in working_bees)}")
  31. if amount_of_nectar:
  32.     print(f"Nectar left: {', '.join(str(x) for x in amount_of_nectar)}")
Advertisement
Add Comment
Please, Sign In to add comment