0

# Driver license in c

I solved this and, It passes all but the last one , I considered that it might be names started with the same letters What to do ? https://code.sololearn.com/cZabgd66i6h9/?ref=app

5 Respostas

0

Side note though, I don't think the time math works out in all cases, so that's probably the real issue. Consider when you're 5th and there are 2 agents: your calculation gives 40 minutes, but since you're in the 3rd group it'll be 60 minutes before you're done.
My first instinct was to just use (1+order/agent), but that doesn't work either, when order%agent=0. So you might need to do some extra work there.

+ 2

If it wants you to compare the whole name, there's not much to do in bare C but to brute force it. Your choice comes down to whether you want to use a for loop or a while loop, mostly, and which syntax you think makes it more readable (ternary vs verbose)

+ 2

Initialize order = 0 instead of 1, then in line 23 add 1 to the formula:
time=(1+order/agent)*20;
Then you may optionally delete lines 20-22, since the corrected time formula will work for all cases.
Consider using the string library function strcmp() for string comparisons so that all characters will get checked if needed.
Edit: Now I see you got it fixed while I was composing my answer. Good job! 👍

0

Orin Cook
You were right , that was the mistake , i fixed it and it worked !
🙏

0

I know it's too late to answer this since you have done the challenge, but..
You can remove all names that comes after the given name in a sorted group, in another lists(Idk if C has this one because I'm not a C programmer). This helps you to solve the problem easily.
This is how I solve this problem in Python. Idk if this one works for C, but I hope youll be solving even harder problems like this in the future.