Advertisement
Merucial

High Jump

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