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))

6 Respostas

+ 3

Your last line has some issue.

+ 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)

+ 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

+ 1

Went to read a bit about the math module and a ceil in particular. Thanks :)

0

Give me a clue :)

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)