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?
5/20/2021 6:45:56 AMSwapnil Kamdi
7 AnswersNew Answer
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.
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)
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.
Quantum above given is working
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.
About which language you are talking about Quantum
Yes it is