New driver's license test 5 failed | Sololearn: Learn to code for FREE!

+1

New driver's license test 5 failed

https://code.sololearn.com/c9rzrDU8HHGC/?ref=app

2/26/2020 8:09:34 PM

Arthur Barbosa

4 Answers

New Answer

+2

Michael 2 Anna John Nancy Vera output: 20 expected output: 40

+2

Arthur Barbosa in the example with the input from Denise's example: Michael 2 Anna John Nancy Vera After sorting you calculate your position to be 3 and then multiply by 20. This is 60. Then you subtract agents (2) * 20 which is 40. 60-40=20 which is not correct. Position 3 should be 40. Two people , 2 agents is 20 minutes. Then your next for 20 minutes. So that's 40.

+1

Thank you everybody!! I changed my code, now is working perfectly!

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)