+ 4

# [SOLVED]Code-Coach Challenge : How Far ?

Hey Guys Ryan Here, I Wrote A Code For This Code Coach Challenge But Getting Error In Test Case #3 And #4. Here Is My Solution Can You Please Tell Me Bug Or Error Inside My Code. My Solution : https://code.sololearn.com/cLb163ICe3jM/?ref=app

13th Jun 2020, 4:52 AM
Rahul Saxena
12 ответов
+ 5
Try this shorter code, a=input() x = a.rstrip("B") y=x.lstrip("B") count=0 for i in y: count+=1 print(count-2) code by SYED SAIF
10th Feb 2021, 6:15 AM
Twilight🌅
+ 3
Ohh that's great👍👍😇😇
13th Jun 2020, 5:43 AM
SOUMYA
+ 2
Thanks 𝕊𝕆𝕌𝕄𝕐𝔸 𝕊𝔸ℍ𝕌 But I Already Solved It Few Minutes Before 😊😊.
13th Jun 2020, 5:36 AM
Rahul Saxena
+ 2
STEP = 1 s = input() h = s.find('H') p = s.find('P') if p > h: print(p-h-STEP) else: print(h-p-STEP)
4th Nov 2022, 10:30 PM
Apongpoh Gilbert
+ 1
Ryan Daniel Most of the users don't have pro account so please also upload the question so more people can help you. Thanks!
13th Jun 2020, 5:09 AM
+ 1
13th Jun 2020, 5:19 AM
Rahul Saxena
+ 1
Check it out‼ 👇👇👇👇 x=input("enter=") print(x,"\n\n") a,b=0,0 for i in x: if i=='H': a=x.index(i) elif i=='P': b=x.index(i) print(abs(a-b)-1)
13th Jun 2020, 5:34 AM
SOUMYA
+ 1
\$hanthi Reddy that's great ... Keep it up 👍
14th Feb 2021, 2:22 PM
Syedsaif
+ 1
a = input() h = a.index('H') p = a.index('P') blocks = (p - h - 1) if p > h else (p + h - 1) print(blocks)
22nd Apr 2023, 3:59 AM
William Mabotja
0
My take: a = input() h = a.index('H') p = a.index('P') blocks = (p - h - 1) if p > h else (p + h - 1) print(blocks)
11th Dec 2021, 11:24 PM
Mateo González Bufi
0
Here's my solution, it only passes on 3 out 5 cases, am I missing anything? walk = input() started = False blocks = 0 for i in walk: if i == "H": started = True if started: if i == "B": blocks += 1 elif i == "P": break print(blocks)
19th Mar 2023, 1:12 PM
William Mabotja
0
William Mabotja consider the situation that P comes before H in which case your code will not work.. just giving a guess to why it didn't work
21st Apr 2023, 2:32 PM
Waseem Haidar
Актуальное сегодня
super laggy