ALEXANDAR_GEORGIEV

high_jump

May 29th, 2022 (edited)
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.04 KB | None | 0 0
  1. desired_height = int(input())   # Желана височина в см
  2. open_height = desired_height - 30
  3. unsuccessful_jump = 0
  4. jumps = 0
  5. limit_height = open_height
  6. check_desired_height = False
  7. while True:
  8.     current_height = int(input())
  9.     jumps += 1
  10.  
  11.     if current_height > limit_height:
  12.         #if current_height > desired_height:
  13.         if limit_height == desired_height:  # Задачата се решава, само ако летвата е на желаната височина и скока е по-висок
  14.             check_desired_height = True
  15.             break
  16.         unsuccessful_jump = 0
  17.         limit_height += 5
  18.     # elif current_height > limit_height and current_height == desired_height:
  19.     #     check_desired_height = True
  20.     #     break
  21.     else:
  22.         unsuccessful_jump += 1
  23.         if unsuccessful_jump > 2: break
  24. if check_desired_height:
  25.     print(f"Tihomir succeeded, he jumped over {limit_height}cm after {jumps} jumps.")
  26. else:
  27.     print(f"Tihomir failed at {limit_height}cm after {jumps} jumps.")
Add Comment
Please, Sign In to add comment