0

New Driver's Licence

You have to get a new driver's license and you show up at the office at the same time as 4 other people. The office says that they will see everyone in alphabetical order and it takes 20 minutes for them to process each new license. All of the agents are available now, and they can each see one customer at a time. How long will it take for you to walk out of the office with your new license? Task Given everyone's name that showed up at the same time, determine how long it will take to get your new license. Sample Input 'Eric' 2 'Adam Caroline Rebecca Frank' Sample Output 40 e = input() f = int(input()) a = input() g = a.split() g.append(e) g.sort() for i in g: if i == e: d = g.index(i) if f == 1: print((d+1)*20) elif f > 1 and d<=(f-1): print(20) elif f == 2 and d > (f-1) and d %2 == 0 and d > 3: print(40) else: print(20) In above 2 cases are approved rest 3 are locked and my attempt isn't getting approved. Where's I'm wrong?

20th May 2021, 6:45 AM
Swapnil Kamdi
Swapnil Kamdi - avatar
10 Answers
+ 2
Swapnil Kamdi Let's say C/C++, Java etc. Python has a huge range of libraries for almost everything. I still get surprised when I sometimes see examples of what they are capable of with a few lines of code.
20th May 2021, 2:24 PM
Jan
Jan - avatar
+ 1
Instead of doing all that stuff, you can directly compute the value and print. No need of for loops and all.. print(int(g.index(e)//f)*20 + 20)
20th May 2021, 6:56 AM
sarada lakshmi
sarada lakshmi - avatar
+ 1
There is a bug in that task you have to pass, and you can even solve it without checking for all possible conditions which I discovered by a coincidence when I made changes to have it pass all test cases.
20th May 2021, 10:39 AM
Jan
Jan - avatar
0
Quantum above given is working
20th May 2021, 11:29 AM
Swapnil Kamdi
Swapnil Kamdi - avatar
0
Swapnil Kamdi But it will only work in Python, because that languange has a million mathematical smart functions to reduce almost all code to one line.
20th May 2021, 12:30 PM
Jan
Jan - avatar
0
About which language you are talking about Quantum
20th May 2021, 1:54 PM
Swapnil Kamdi
Swapnil Kamdi - avatar
0
Yes it is
20th May 2021, 2:43 PM
Swapnil Kamdi
Swapnil Kamdi - avatar
0
myname = input() num_agents = int(input()) other_names = list(input().split()) other_names.append(myname) other_names.sort() ind_myname = other_names.index(myname)+1 print('20' if ind_myname <=num_agents else (ind_myname-num_agents)*20+20)
25th Nov 2021, 10:27 PM
Mas'ud Saleh
Mas'ud Saleh - avatar
0
Hi, could someone tell me what's wrong here? myName = str(input()) numOfAgents =int(input()) otherPeople =input().split() allOfUs= otherPeople.append(myName) allOfUs.sort() myNumber= allOfUs.index(myName) if (myNumber+1) <= numOfAgents: print(20) else: print(((myNumber+1)-numOfAgents)*20+20)
14th Feb 2022, 4:34 PM
Danica Dujaković
Danica Dujaković - avatar
- 1
14th Feb 2022, 6:49 PM
Swapnil Kamdi
Swapnil Kamdi - avatar