Advertisement
Guest User

08. Seize the Fire

a guest
Feb 5th, 2020
398
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.80 KB | None | 0 0
  1. string = input().split('#')
  2. water = int(input())
  3.  
  4. effort = 0
  5. total_fire = 0
  6. valid = False
  7.  
  8. put_out_cells = []
  9.  
  10. for command in string:
  11.     arg = command.split(' = ')
  12.     fire_type = arg[0]
  13.     fire_lvl = int(arg[1])
  14.  
  15.     if water < fire_lvl:
  16.         continue
  17.  
  18.     if fire_type == 'High' and fire_lvl in range(81, 126):
  19.         valid = True
  20.     elif fire_type == 'Medium' and fire_lvl in range(51, 81):
  21.         valid = True
  22.     elif fire_type == 'Low' and fire_lvl in range(1, 51):
  23.         valid = True
  24.  
  25.     if valid:
  26.         put_out_cells.append(fire_lvl)
  27.         water -= fire_lvl
  28.         effort += fire_lvl * 0.25
  29.         total_fire += fire_lvl
  30.  
  31. print('Cells:')
  32.  
  33. for cell in put_out_cells:
  34.     print(f' - {cell}')
  35.  
  36. print(f'Effort: {effort:.2f}')
  37. print(f'Total Fire: {total_fire}')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement