Advertisement
GeorgiLukanov87

high_jump100/100

Mar 31st, 2022
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.25 KB | None | 0 0
  1. to_reach = int(input())
  2. start_jump = to_reach - 30
  3. jump_counter = 1
  4. fail_jump = 0
  5. success_jump = 0
  6. failed = False
  7. current_jump = int(input())
  8. success_after_fail = False
  9. while True:
  10.     if current_jump > start_jump:
  11.         success_jump += 1
  12.         start_jump += 5
  13.         if success_jump == 7 and start_jump > to_reach:
  14.             break
  15.         current_jump = int(input())
  16.         jump_counter += 1
  17.     elif current_jump <= start_jump:
  18.         while fail_jump != 3:
  19.             if current_jump > start_jump:
  20.                 success_jump += 1
  21.                 start_jump += 5
  22.                 fail_jump = 0
  23.             elif current_jump <= start_jump:
  24.                 success_jump = +1
  25.                 fail_jump += 1
  26.             if fail_jump == 3:
  27.                 failed = True
  28.                 continue
  29.             elif fail_jump != 3 and start_jump > to_reach:
  30.                 success_after_fail = True
  31.                 break
  32.             current_jump = int(input())
  33.             jump_counter += 1
  34.         if success_after_fail:
  35.             break
  36.         print(f"Tihomir failed at {start_jump}cm after {jump_counter} jumps.")
  37.         break
  38. if not failed:
  39.     print(f"Tihomir succeeded, he jumped over {to_reach}cm after {jump_counter} jumps.")
  40.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement