Advertisement
Nenogzar

energy = int(input()) distance_to_enemy = input() win_counter = 0 while distance_to_enemy != "End o

Feb 13th, 2024
1,013
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.58 KB | None | 0 0
  1. energy = int(input())
  2. distance_to_enemy = input()
  3. win_counter = 0
  4.  
  5. while distance_to_enemy != "End of battle":
  6.  
  7.     distance_to_enemy = int(distance_to_enemy)
  8.  
  9.     if distance_to_enemy <= energy:
  10.         energy -= distance_to_enemy
  11.         win_counter += 1
  12.     else:
  13.         print(f"Not enough energy! Game ends with {win_counter} won battles and {energy} energy")
  14.         break
  15.  
  16.     if win_counter % 3 == 0:
  17.         energy += win_counter
  18.  
  19.     distance_to_enemy = input()
  20.  
  21. if distance_to_enemy == "End of battle":
  22.     print(f"Won battles: {win_counter}. Energy left: {energy}")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement