Advertisement
im11

06. High Jump

Oct 6th, 2021
1,182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.93 KB | None | 0 0
  1. target = int(input())
  2. bar_height = target - 30
  3. jump_height = int(input())
  4. success_count = 1
  5. fail_count = 0
  6. total_fail_count = 0
  7.  
  8. while bar_height <= target:   # това беше твоя код ---> while bar_height < target:
  9.  
  10.     if bar_height == target and jump_height > target:   # този ред аз го дописах
  11.         break   # този ред аз го дописах
  12.  
  13.     if jump_height > bar_height:
  14.         success_count += 1
  15.         fail_count = 0
  16.         bar_height += 5
  17.     else:
  18.         fail_count += 1
  19.         total_fail_count += 1
  20.  
  21.     total_jumps = success_count + total_fail_count
  22.  
  23.     if fail_count == 3:
  24.         print(f"Tihomir failed at {bar_height}cm after {total_jumps - 1} jumps.")
  25.         break
  26.  
  27.     jump_height = int(input())
  28.  
  29. total_jumps = success_count + total_fail_count
  30.  
  31. if fail_count < 3:
  32.     print(f"Tihomir succeeded, he jumped over {bar_height}cm after {total_jumps} jumps.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement