DiYane

Seize the Fire

Jul 31st, 2023 (edited)
862
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.80 KB | None | 0 0
  1. fires = input().split("#")
  2. water = int(input())
  3.  
  4. effort = 0
  5. total_fire = 0
  6. put_out_cells = []
  7.  
  8. print("Cells:")
  9.  
  10. for fire in fires:
  11.     args = fire.split(" = ")
  12.     fire_type = args[0]
  13.     level = int(args[1])
  14.     valid = False
  15.  
  16.  
  17.     if water < level:
  18.         continue
  19.  
  20.     if fire_type == 'High':
  21.         if 81 <= level <= 125:
  22.             valid = True
  23.     elif fire_type == 'Medium':
  24.         if 51 <= level <= 80:
  25.             valid = True
  26.     elif fire_type == 'Low':
  27.         if 1 <= level <= 50:
  28.             valid = True
  29.  
  30.     if valid:
  31.         put_out_cells.append(level)
  32.         water -= level
  33.         effort += level * 0.25
  34.         total_fire += level
  35.  
  36.  
  37. for cell in put_out_cells:
  38.     print(f' - {cell}')
  39.  
  40. print(f'Effort: {effort:.2f}')
  41. print(f'Total Fire: {total_fire}')
Tags: python
Advertisement
Add Comment
Please, Sign In to add comment