This is the practice problem :FLOW007 Problem - CodeChef
This is my solution (using strings in python):CodeChef: Practical coding for everyone
PS: was just experimenting , would appreciate any suggestion on it ![]()
This is the practice problem :FLOW007 Problem - CodeChef
This is my solution (using strings in python):CodeChef: Practical coding for everyone
PS: was just experimenting , would appreciate any suggestion on it ![]()
The translate function will change every โ0โ to None. Try 100010 as input your program returns 11, but the CA is 10001.
Try this:
for i in range(int(input())): #test_cases
number=input()
ans=number[::-1] #reverse and store
k = 0 ;
for x in ans: #loop through to remove zeroes at the beginning
if x =='0': #delete the character from the string
k += 1 ;
else: #exit as soon as a non zero number is found :)
break
print(ans[k:])
#doubt
but i have included a break statement once x!=0, i,e once a string other than 0 is encountered it stops doing that, i tested the result on compiler it was satisfied for the given sample test(the results were correct)
Anyways thankyou for the quick response
, i think i shouldnโt have complicated the process using some function which i dont know completely about and just searched for it on the web.
Thnks for the solution as well i will appreciate if u could clarify on my #doubt , thnkx again 
letโs look at this if block
if x=='0':
ans = ans.translate({ord(x): None})
It says that if the first digit is โ0โ, call ans.translate({ord(x): None} which will do nothing but convert all zeroes in ans string to None, Keep in mind not only first but it converts all zeroes int ans to None and thats why you are getting WA for TCs like 100010.
Oh i get it , so the time i call it it just replaced all 0โs to None ,
thanks for taking time to clarify it