SHARE
TWEET

Untitled

a guest Feb 27th, 2020 89 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. target_height = int(input())
  2.  
  3. start_height = target_height - 30
  4.  
  5. unsuccessful_tries = 0
  6. total_tries = 0
  7.  
  8.  
  9. while unsuccessful_tries < 3 and start_height <= target_height:
  10.     try_height = int(input())
  11.     if start_height > target_height:
  12.         total_tries += 1
  13.         break
  14.     for tries in range(3):
  15.         if try_height > start_height:
  16.             start_height += 5
  17.             total_tries += 1
  18.             unsuccessful_tries = 0
  19.             break
  20.  
  21.         elif try_height <= start_height:
  22.             unsuccessful_tries += 1
  23.             total_tries += 1
  24.             if unsuccessful_tries == 3:
  25.                 break
  26.             elif unsuccessful_tries < 3:
  27.                 try_height = int(input())
  28.  
  29. if unsuccessful_tries == 3:
  30.     print(f"Tihomir failed at {start_height}cm after {total_tries} jumps.")
  31.  
  32.  
  33. if start_height > target_height:
  34.     print(f"Tihomir succeeded, he jumped over {start_height - 5}cm after {total_tries} 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