Advertisement
Spocoman

08. Seize the Fire

Jan 23rd, 2022
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.68 KB | None | 0 0
  1. fires = input().split('#')
  2. water = int(input())
  3.  
  4. effort = 0
  5. total_fire = 0
  6.  
  7. for item in range(len(fires)):
  8.     fire = fires[item].split(' = ')
  9.     valid ={'Low': 1 <= int(fire[1]) <= 50,
  10.             'Medium': 51 <= int(fire[1]) <= 80,
  11.             'High': 81 <= int(fire[1]) <= 125 }
  12.  
  13.     if valid[fire[0]] and water >= int(fire[1]):
  14.         effort += int(fire[1]) / 4
  15.         total_fire += int(fire[1])
  16.         fires[item] = int(fire[1])
  17.         water -= int(fire[1])
  18.     else:
  19.         fires[item] = ''
  20.  
  21. fires = list(filter(lambda a: a != '', fires))
  22. print('Cells:')
  23.  
  24. for fire in fires:
  25.     print(f' - {fire}')
  26.  
  27. print(f'Effort: {effort:.2f}\nTotal Fire: {total_fire}')
  28.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement