Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from collections import deque
- fires_effects_que = deque([int(n) for n in input().split(', ')])
- explosive_power_stack = [int(n) for n in input().split(', ')]
- fire_works = {'Palm': 0, 'Willow': 0, 'Crossette': 0}
- while fires_effects_que and explosive_power_stack and (fire_works['Palm'] < 3 or fire_works['Willow'] < 3
- or fire_works['Crossette'] < 3):
- current_fire_effect = fires_effects_que.popleft()
- current_explosive = explosive_power_stack.pop()
- if current_explosive <= 0 and current_fire_effect <= 0:
- continue
- elif current_explosive <= 0:
- fires_effects_que.appendleft(current_fire_effect)
- continue
- elif current_fire_effect <= 0:
- explosive_power_stack.append(current_explosive)
- continue
- mixture = current_explosive + current_fire_effect
- if mixture % 3 != 0 and mixture % 5 != 0:
- current_fire_effect -= 1
- fires_effects_que.append(current_fire_effect)
- explosive_power_stack.append(current_explosive)
- continue
- elif mixture % 3 == 0 and mixture % 5 != 0:
- fire_works['Palm'] += 1
- elif mixture % 3 != 0 and mixture % 5 == 0:
- fire_works['Willow'] += 1
- elif mixture % 3 == 0 and mixture % 5 == 0:
- fire_works['Crossette'] += 1
- if fire_works['Palm'] >= 3 and fire_works['Willow'] >= 3 and fire_works['Crossette'] >= 3:
- print("Congrats! You made the perfect firework show!")
- else:
- print("Sorry. You can't make the perfect firework show.")
- if fires_effects_que:
- print(f"Firework Effects left: {', '.join([str(n) for n in fires_effects_que])}")
- if explosive_power_stack:
- print(f"Explosive Power left: {', '.join([str(n) for n in explosive_power_stack])}")
- print(f"""Palm Fireworks: {fire_works['Palm']}
- Willow Fireworks: {fire_works['Willow']}
- Crossette Fireworks: {fire_works['Crossette']}""")
Advertisement
Add Comment
Please, Sign In to add comment