SHARE
TWEET

High Jump

Merucial Mar 26th, 2020 (edited) 79 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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.")
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top