0
Can anyone help me to resolve the driver's licence problem?? I got 3/5 test cases passed
10 odpowiedzi
+ 3
n = str(input()) #name
a = int(input()) #number of agents available
w = str(input()) #waiters list
w = w.split(" ")
w.append(n)#add to list
w = sorted(w)#sort the list
q = (w.index(n)) #find index of the name
t =((q//a)*20)+20#find time
print(t)#print time
My code worked perfectly by just taking the index as it is.
+ 2
I did
import math
n = str(input()) #name
a = int(input()) #number of agents available
w = str(input()) #waiters list
w = w.split(" ")
w.append(n)#add to list
w = sorted(w)#sort the list
q = (w.index(n))+1 #find index of the name
sw = len(w)
if a % 2 != 0:
if sw % 2 != 0:
if len(w) != q:
t =(q//a)*20#find time
else:
a = a - 1
t =(q//a)*20
print(k)
But it crushes without a reason
probably interpreter malfunction
+ 1
Yes but what's your code this link shows mine
make a code playground save and share it
+ 1
n = str(input()) #name
a = int(input()) #number of agents available
w = str(input()) #waiters list
w = w.split(" ")
w.append(n)#add to list
w = sorted(w)#sort the list
q = (w.index(n))+1 #find index of the name
t =(q//a)*20#find time
print(t)
this is the code I used.
+ 1
import math
n = str(input()) #name
a = int(input()) #number of agents available
w = str(input()) #waiters list
w = w.split(" ")
w.append(n)#add to list
w = sorted(w)#sort the list
q = (w.index(n))+1 #find index of the name
sw = len(w)
if a % 2 == 0:
if sw % 2 == 0:
if len(w) == q:
t = q//a
ta = t * 20
else:
if a != 1: a = a - 1
t = q//a
ta = t * 20
print(ta)
I made the case 5 work and messed the 4
0
Well what happens if you are 5 people you go to the line of 2 or 3
0
In my code in the que of 5 people including input with line of 2 agents then as per my code o/p will be 60.
0
Yes it may be a malfunction as you said bro
0
Can you try it on PC and tell me what's the error
0
#first (long) way
ur_name = input()
agents = int(input())
names = input().split()
names.append(ur_name)
names.sort()
time = 20
count = 0
while ur_name in names:
for i in range(agents):
names.pop(0)
count+=1
print(time*count)
#second way
ur_name = input()
agents = int(input())
names = input().split()
names.append(ur_name)
names.sort()
me = names.index(ur_name)
print(me//agents*20+20)
#this way is cool IMO
ur_name, agents, names = input(), int(input()),input().split()
names.append(ur_name)
names.sort()
me = names.index(ur_name)
print(me//agents*20+20)