Advertisement
Guest User

04. Honey

a guest
Jan 25th, 2023
349
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.13 KB | None | 0 0
  1. def honey_calculator(worker_bee, operation, nectar_collected):
  2.     if operation == '+':
  3.         return abs(worker_bee + nectar_collected)
  4.     elif operation == '-':
  5.         return abs(worker_bee - nectar_collected)
  6.     elif operation == '*':
  7.         return abs(worker_bee * nectar_collected)
  8.     elif operation == '/':
  9.         return abs(worker_bee / nectar_collected)
  10.  
  11.  
  12. working_bees = [int(x) for x in input().split()]
  13. total_nectar = [int(x) for x in input().split()]
  14. symbols = input().split()
  15.  
  16. collected_nectar = 0
  17. collected_honey = 0
  18.  
  19. while working_bees and total_nectar:
  20.     bee = working_bees[0]
  21.     nectar = total_nectar[-1]
  22.  
  23.     if nectar >= bee:
  24.         collected_nectar = nectar
  25.  
  26.     elif nectar < bee:
  27.         total_nectar.pop()
  28.         continue
  29.  
  30.     collected_honey += honey_calculator(bee, symbols[0], collected_nectar)
  31.     working_bees.pop(0)
  32.     total_nectar.pop()
  33.     symbols.pop(0)
  34.  
  35. print(f"Total honey made: {collected_honey}")
  36.  
  37. if working_bees:
  38.     print(f"Bees left: {', '.join([str(x) for x in working_bees])}")
  39. if total_nectar:
  40.     print(f"Nectar left: {', '.join([str(x) for x in total_nectar])}")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement