0

Driver license task solution. Can’t get what’s wrong

3 of 5 tests passed successfully. What’s wrong with other 2 - I don’t know. https://sololearn.com/coach/18/?ref=app I wrote a solution code step-by-step to make sure the logic is correct. Check it and point the issue if you see it. Thanks. ———————- name = input() agents = int(input()) people = input() allpeople = people + " " + name allpeople = allpeople.split(" ") allpeople.sort() print(int((allpeople.index(name)+1)*20/agents))

22nd Apr 2021, 6:39 PM
Oleg Avrah
6 ответов
+ 3
Your last line has some issue.
22nd Apr 2021, 6:44 PM
minirkk
minirkk - avatar
+ 2
first clue: int won't give a accurate value. (so either ceil or floor would do)? second clue: The logic is little bit different, 20 need sto be multiplied with value you got in (first clue) ---------------------------------- SPOILER: from math import ceil name = input() agents = int(input()) people = input() allpeople = people + " " + name allpeople = allpeople.split(" ") allpeople.sort() print(ceil((allpeople.index(name)+1)/agents)*20)
22nd Apr 2021, 7:06 PM
minirkk
minirkk - avatar
+ 1
Oleg Avrah If you think carefully about the logic of the last statement in the problem, you'll be able to notice that 20 has to be multiplied with the ceiled value of the allpeople.index(name) + 1. Here's a simplified version for illustration: from math import ceil a, b = input(), int(input()) c = sorted(input().split()+[a]) print(20*ceil((c.index(a)+1)/b)) # A practical ceil() implementation: # var//1 + (var//1 < var) # Hope this helps
22nd Apr 2021, 7:19 PM
Calvin Thomas
Calvin Thomas - avatar
+ 1
Went to read a bit about the math module and a ceil in particular. Thanks :)
23rd Apr 2021, 3:53 AM
Oleg Avrah
0
Give me a clue :)
22nd Apr 2021, 7:00 PM
Oleg Avrah
0
a=input() b=int(input()) c=input().split() c.append(a) x=sorted(c) y=x.index(a)+1 if y%b==0: print(y//b*20) else: print(y//b*20+20)
29th Dec 2021, 2:07 PM
Ayu Lestari Gunawan