Advertisement
Guest User

high_jump

a guest
Feb 7th, 2020
785
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.60 KB | None | 0 0
  1. target = int(input())
  2. starting_height = target - 30
  3.  
  4. total_jumps = 0
  5. fail_jumps = 0
  6. failed = False
  7.  
  8. while not failed:
  9.     attempt = int(input())
  10.     total_jumps += 1
  11.  
  12.     if attempt <= starting_height:
  13.         fail_jumps += 1
  14.         if fail_jumps == 3:
  15.             failed = True
  16.     else:
  17.         if starting_height >= target:
  18.             break
  19.         fail_jumps = 0
  20.         starting_height += 5
  21.  
  22. if failed:
  23.     print(f'Tihomir failed at {starting_height}cm after {total_jumps} jumps.')
  24. else:
  25.     print(f'Tihomir succeeded, he jumped over {starting_height}cm after {total_jumps} jumps.')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement