Advertisement
bl00dt3ars

06. High Jump

Dec 2nd, 2020
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.51 KB | None | 0 0
  1. target_height = int(input())
  2. current_height = target_height - 30
  3. fails = 0
  4. total_jumps = 0
  5.  
  6. while fails < 3 and current_height <= target_height:
  7.     jump = int(input())
  8.     total_jumps += 1
  9.     if jump > current_height:
  10.         current_height += 5
  11.         fails = 0
  12.     else:
  13.         fails += 1
  14.  
  15. if current_height <= target_height:
  16.     print(f"Tihomir failed at {current_height}cm after {total_jumps} jumps.")
  17. else:
  18.     print(f"Tihomir succeeded, he jumped over {target_height}cm after {total_jumps} jumps.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement