Driver license challenge (python), one failed test case | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Driver license challenge (python), one failed test case

https://www.sololearn.com/coach/18?ref=app I have one failed test case (the others four are green), I can't understand where the issue is. The code: me = input() numagents = int(input()) others = input() turntime=20 drivers = others.split() drivers.append(str(me)) drivers.sort() mypos=drivers.index(me)+1 turns = (mypos // numagents) + (mypos % numagents) print(turns * turntime)

15th Mar 2020, 5:46 PM
Federico Bianco
4 Answers
0
It failing the test cases when numagents=5 Output should 20 only for all positions but giving 40.
15th Mar 2020, 6:56 PM
Jayakrishna 🇮🇳
0
Sorry for the late answer. I just tried my code with a sample input (and 5 agents) and It gives the correct answer if "My" name is either the first or the last in the order. So I don't know why you'd say It gives 40...
10th Apr 2020, 7:10 PM
Federico Bianco
0
Federico Bianco As you said it gives 20 for agents=1 or 5. But there may be cases agents=2 or 3 or 4 For those check output, 40, 60, 80.
11th Apr 2020, 10:06 AM
Jayakrishna 🇮🇳
0
let say we have mypos = 1 and numagents = 3 so: turns = 1/3 + 1%3 = 2/3 print ( 2/3* 20) output = 13.333 and thats wrong. In your calculation you do not consider that all employees of the driver office finish at the same time every 20 min! so better would be: turns = int(mypos/numagents) if mypos%numagents != 0: turns += 1 print (turns * turntime) result: 20
23rd Jun 2020, 11:12 AM
Jonny