# test

Feb 13th, 2024
941
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. def check_win_counter(energy, distance_to_enemy, win_counter):
2.     if distance_to_enemy <= energy:
3.         energy -= distance_to_enemy
4.         win_counter += 1
5.     else:
6.         print(f"Not enough energy! Game ends with {win_counter} won battles and {energy} energy")
7.         #return False
8.
9.     if win_counter % 3 == 0:
10.         energy += win_counter
11.
12.     return win_counter, energy
13.
14.
15. energy = int(input())
16. distance_to_enemy = input()
17. win_counter = 0
18.
19. while distance_to_enemy != "End of battle":
20.     distance_to_enemy = int(distance_to_enemy)
21.
22.     result = check_win_counter(energy, distance_to_enemy, win_counter)
23.     if not result:
24.         break  # exit the loop if the game ends
25.
26.     win_counter, energy = result
27.
28.     distance_to_enemy = input()
29.
30. if distance_to_enemy == "End of battle":
31.     print(f"Won battles: {win_counter}. Energy left: {energy}")