0

What's gone wrong in the below Driver License code coach problem

https://www.sololearn.com/coach/18?ref=app name=input() num=int(input()) names=input() list=names.split(" ") list.append(name) list.sort() k=1 for i in list: if(i!=name): k+=1 else: break if(k==num): print(20) else: res=(k//num)*20 print(res)

1st Feb 2020, 2:31 PM
Shobhith J B
Shobhith J B - avatar
6 odpowiedzi
0
Yes. That also works exactly...
8th Feb 2020, 5:52 PM
Jayakrishna 🇮🇳
+ 1
I went for math.ceil too: #organizing inputs me=str(input()) agents=int(input()) others=input().split() time=20 #adding me and sorting others.append(me) list_az=others list_az.sort() #work out order myturn=list_az.index(me)+1 list_tot=format(len(list_az)) turn_ag=myturn/agents #work out waiting time import math if myturn<=agents: print(20) else: print(int(math.ceil(turn_ag)*time)) Can you explain me the k, k+=1 solution?
20th Feb 2020, 9:48 AM
Salvatore Junior Iaccarino
Salvatore Junior Iaccarino - avatar
0
I have put conditions for that but still same
1st Feb 2020, 2:54 PM
Shobhith J B
Shobhith J B - avatar
0
Shobhith J B No. Am saying for those condition, your getting output zero. But required output is 20. So check out for that. May be you need to find better approach to check special cases. Before that check like this: Instead of k==m, try by if(k<=num) print(20)
1st Feb 2020, 2:59 PM
Jayakrishna 🇮🇳
0
I understood the problem the division is not k//num it should be math.ceil(k/num)
8th Feb 2020, 3:47 PM
Shobhith J B
Shobhith J B - avatar
- 1
Ex: case, If person is 2nd place, and no. Of agents=3, then res=0 All cases if k<num =>2<3, 3<4, 4<5 then res=0.
1st Feb 2020, 2:53 PM
Jayakrishna 🇮🇳