Advertisement
go6odn28

high_jump.

Oct 13th, 2023
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.82 KB | None | 0 0
  1. def jump_successful(h, j):
  2.     if j > h:
  3.         return True
  4.     elif j <= h:
  5.         return False
  6.  
  7. tihomir_aim = int(input())
  8. jumps_number = 0
  9. fail = False
  10. bar_height = tihomir_aim - 30
  11. while True:
  12.     attempt = 3
  13.  
  14.     while attempt > 0:
  15.         jump = int(input())
  16.         jumps_number += 1
  17.         if jump_successful(bar_height, jump):
  18.             bar_height += 5
  19.             break
  20.         elif not jump_successful(bar_height, jump):
  21.             attempt -= 1
  22.             if attempt == 0:
  23.                 fail = True
  24.                 break
  25.  
  26.     if fail:
  27.         break
  28.     if bar_height > tihomir_aim:
  29.         break
  30.  
  31. if not fail:
  32.     print(f"Tihomir succeeded, he jumped over {tihomir_aim}cm after {jumps_number} jumps.")
  33. elif fail:
  34.     print(f"Tihomir failed at {bar_height}cm after {jumps_number} jumps.")
  35.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement