viligen

fireworks_show

Jan 31st, 2022
674
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.90 KB | None | 0 0
  1. from collections import deque
  2.  
  3. fires_effects_que = deque([int(n) for n in input().split(', ')])
  4. explosive_power_stack = [int(n) for n in input().split(', ')]
  5.  
  6. fire_works = {'Palm': 0, 'Willow': 0, 'Crossette': 0}
  7.  
  8. while fires_effects_que and explosive_power_stack and (fire_works['Palm'] < 3 or fire_works['Willow'] < 3
  9.                                                        or fire_works['Crossette'] < 3):
  10.     current_fire_effect = fires_effects_que.popleft()
  11.     current_explosive = explosive_power_stack.pop()
  12.     if current_explosive <= 0 and current_fire_effect <= 0:
  13.         continue
  14.     elif current_explosive <= 0:
  15.         fires_effects_que.appendleft(current_fire_effect)
  16.         continue
  17.     elif current_fire_effect <= 0:
  18.         explosive_power_stack.append(current_explosive)
  19.         continue
  20.     mixture = current_explosive + current_fire_effect
  21.     if mixture % 3 != 0 and mixture % 5 != 0:
  22.         current_fire_effect -= 1
  23.         fires_effects_que.append(current_fire_effect)
  24.         explosive_power_stack.append(current_explosive)
  25.         continue
  26.     elif mixture % 3 == 0 and mixture % 5 != 0:
  27.         fire_works['Palm'] += 1
  28.     elif mixture % 3 != 0 and mixture % 5 == 0:
  29.         fire_works['Willow'] += 1
  30.     elif mixture % 3 == 0 and mixture % 5 == 0:
  31.         fire_works['Crossette'] += 1
  32.  
  33. if fire_works['Palm'] >= 3 and fire_works['Willow'] >= 3 and fire_works['Crossette'] >= 3:
  34.     print("Congrats! You made the perfect firework show!")
  35. else:
  36.     print("Sorry. You can't make the perfect firework show.")
  37.  
  38. if fires_effects_que:
  39.     print(f"Firework Effects left: {', '.join([str(n) for n in fires_effects_que])}")
  40. if explosive_power_stack:
  41.     print(f"Explosive Power left: {', '.join([str(n) for n in explosive_power_stack])}")
  42.  
  43. print(f"""Palm Fireworks: {fire_works['Palm']}
  44. Willow Fireworks: {fire_works['Willow']}
  45. Crossette Fireworks: {fire_works['Crossette']}""")
  46.  
Advertisement
Add Comment
Please, Sign In to add comment