Sichanov

high jump

Aug 14th, 2021 (edited)
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.94 KB | None | 0 0
  1. target_height = int(input())
  2. starting_height = target_height - 30
  3. success_counter = 0
  4. current_fails_counter = 0
  5. total_fails_counter = 0
  6. max_height = 0
  7. jumps = 0
  8. for set_height in range(starting_height, target_height + 1, 5):
  9.     current_jump_height = int(input())
  10.     while True:
  11.         jumps += 1
  12.         if current_jump_height > set_height:
  13.             current_fails_counter = 0
  14.             max_height = current_jump_height
  15.             break
  16.         else:
  17.             current_fails_counter += 1
  18.             max_height = set_height
  19.             if current_fails_counter == 3:
  20.                 break
  21.             else:
  22.                 current_jump_height = int(input())
  23.                 continue
  24.     if current_fails_counter == 3:
  25.         break
  26.  
  27. if target_height < max_height:
  28.     print(f"Tihomir succeeded, he jumped over {target_height}cm after {jumps} jumps.")
  29. else:
  30.     print(f"Tihomir failed at {max_height}cm after {jumps} jumps.")
Add Comment
Please, Sign In to add comment