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)
6 Respostas
0
Yes. That also works exactly...
+ 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?
0
I have put conditions for that but still same
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)
0
I understood the problem the division is not k//num it should be math.ceil(k/num)
- 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.