Advertisement
mmishanchyk

Untitled

Jun 16th, 2021
926
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.56 KB | None | 0 0
  1. from collections import deque
  2.  
  3. fireworks_effect = deque()
  4.  
  5. for el in input().split(", "):
  6.     if int(el) > 0:
  7.         fireworks_effect.append(int(el))
  8.  
  9. explosive_power = [int(el) for el in input().split(", ") if int(el) > 0]
  10.  
  11. palm_firework = 0
  12. willow_firework = 0
  13. crossette_firework = 0
  14.  
  15. while fireworks_effect and explosive_power:
  16.  
  17.     first_effect = fireworks_effect.popleft()
  18.     last_explosive_power = explosive_power.pop()
  19.     effect_sum = first_effect + last_explosive_power
  20.  
  21.     if effect_sum % 3 == 0 and effect_sum % 5 != 0:
  22.         palm_firework += 1
  23.     elif effect_sum % 5 == 0 and effect_sum % 3 != 0:
  24.         willow_firework += 1
  25.     elif effect_sum % 3 == 0 and effect_sum % 5 == 0:
  26.         crossette_firework += 1
  27.     else:
  28.         first_effect -= 1
  29.         fireworks_effect.append(first_effect)
  30.         explosive_power.append(last_explosive_power)
  31.  
  32.     if palm_firework >= 3 and willow_firework >= 3 and crossette_firework >= 3:
  33.         print("Congrats! You made the perfect firework show!")
  34.         print(f"Palm Fireworks: {palm_firework}")
  35.         print(f"Willow Fireworks: {willow_firework}")
  36.         print(f"Crossette Fireworks: {crossette_firework}")
  37.         break
  38. if palm_firework < 3 or willow_firework < 3 or crossette_firework < 3:
  39.     print("Sorry. You can't make the perfect firework show.")
  40.     print(f"Explosive Power left: {', '.join([str(el) for el in explosive_power])}")
  41.     print(f"Palm Fireworks: {palm_firework}")
  42.     print(f"Willow Fireworks: {willow_firework}")
  43.     print(f"Crossette Fireworks: {crossette_firework}")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement