+ 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
Rahul Saxena - avatar
12 Respuestas
+ 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🌅
Twilight🌅 - avatar
+ 3
Ohh that's great👍👍😇😇
13th Jun 2020, 5:43 AM
SOUMYA
SOUMYA - avatar
+ 2
Thanks 𝕊𝕆𝕌𝕄𝕐𝔸 𝕊𝔸ℍ𝕌 But I Already Solved It Few Minutes Before 😊😊.
13th Jun 2020, 5:36 AM
Rahul Saxena
Rahul Saxena - avatar
+ 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
Apongpoh Gilbert - avatar
+ 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
Hacker Badshah
Hacker Badshah - avatar
+ 1
Hacker Badshah I Uploaded Question Inside Codebox.
13th Jun 2020, 5:19 AM
Rahul Saxena
Rahul Saxena - avatar
+ 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
SOUMYA - avatar
+ 1
$hanthi Reddy that's great ... Keep it up 👍
14th Feb 2021, 2:22 PM
Syedsaif
Syedsaif - avatar
+ 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
William Mabotja - avatar
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
Mateo González Bufi - avatar
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
William Mabotja - avatar
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
Waseem Haidar - avatar