Advertisement
Guest User

Untitled

a guest
Apr 11th, 2022
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.10 KB | None | 0 0
  1. from collections import deque
  2.  
  3. fireworks_effects = deque([int(x) for x in input().split(', ')])  # queue
  4. explosive_power = [int(x) for x in input().split(', ')]  # stack
  5.  
  6. palm_firework_count = 0
  7. willow_firework_count = 0
  8. crossette_firework_count = 0
  9.  
  10.  
  11. while True:
  12.     if (not fireworks_effects) or (not explosive_power) or (palm_firework_count >= 3 and willow_firework_count >= 3 and crossette_firework_count >= 3):
  13.         break
  14.  
  15.     effect = fireworks_effects.popleft()
  16.     power = explosive_power.pop()
  17.  
  18.     if effect <= 0:
  19.         explosive_power.append(power)
  20.         continue
  21.  
  22.     if power <= 0:
  23.         fireworks_effects.appendleft(effect)
  24.         continue
  25.  
  26.     action = effect + power
  27.  
  28.     if action % 3 == 0 and action % 5 == 0:
  29.         crossette_firework_count += 1
  30.  
  31.     elif action % 3 == 0 and action % 5 != 0:
  32.         palm_firework_count += 1
  33.  
  34.     elif action % 5 == 0 and action % 3 != 0:
  35.         willow_firework_count += 1
  36.  
  37.     else:
  38.         effect -= 1
  39.         fireworks_effects.append(effect)
  40.         explosive_power.append(power)
  41.  
  42. if palm_firework_count >= 3 and willow_firework_count >= 3 and crossette_firework_count >= 3:
  43.     print("Congrats! You made the perfect firework show!")
  44.  
  45.     if fireworks_effects:
  46.         print(f'Firework Effects left: {", ".join(str(s) for s in fireworks_effects)}')
  47.  
  48.     if explosive_power:
  49.         print(f'Explosive Power left: {", ".join(str(s) for s in explosive_power)}')
  50.  
  51.     print(f'Palm Fireworks: {palm_firework_count}')
  52.     print(f'Willow Fireworks: {willow_firework_count}')
  53.     print(f'Crossette Fireworks: {crossette_firework_count}')
  54.  
  55. else:
  56.     print("Sorry. You can't make the perfect firework show.")
  57.  
  58.     if fireworks_effects:
  59.         print(f'Firework Effects left: {", ".join(str(s) for s in fireworks_effects)}')
  60.  
  61.     if explosive_power:
  62.         print(f'Explosive Power left: {", ".join(str(s) for s in explosive_power)}')
  63.  
  64.     print(f'Palm Fireworks: {palm_firework_count}')
  65.     print(f'Willow Fireworks: {willow_firework_count}')
  66.     print(f'Crossette Fireworks: {crossette_firework_count}')
  67.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement