Fail to pass sololearn task again :( | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Fail to pass sololearn task again :(

The code is supposed to solve the task called "Land ho!", It succeeds to pass 4 of 5. Here is the script: import sys people_ahead = int(input()) one_way = 10 if people_ahead < 20: print(one_way) sys.exit() while one_way <= people_ahead: one_way += 10 print(one_way)

13th Apr 2020, 6:14 PM
Shamil Erkenov
Shamil Erkenov - avatar
6 Answers
+ 3
Hint: How much time do you wait if there are 0..19 people in front of you? What if instead there are 20..39 or 40..59? Do you see any pattern?
14th Apr 2020, 1:30 AM
Diego
Diego - avatar
+ 1
If you noticed what might cause the problem, please just give me a hint don't tell directly 😬
13th Apr 2020, 6:16 PM
Shamil Erkenov
Shamil Erkenov - avatar
+ 1
Here is the info about the task. You are on a large ship and you put down anchor near a beautiful beach. There is a small boat ferrying passengers back and forth, and you get in line for it. How long will you have to wait to get to the beach? You know that 20 people can fit on the boat and each trip to shore takes 10 minutes each way. Task: Determine your wait time if you know the total number of people ahead of you in line. Input Format: An integer that represents the total number of people ahead of you in line. Output Format: An integer that represents the number of minutes that you will have to wait until you are standing on the beach. Sample Input: 15 Sample Output: 10
13th Apr 2020, 6:31 PM
Shamil Erkenov
Shamil Erkenov - avatar
+ 1
Test your code where input is 39 & analyze what is happening
13th Apr 2020, 7:01 PM
Peter Parker
Peter Parker - avatar
+ 1
Diego thank you very much, man. Finally I wrote the next code: people_ahead = int(input()) output = (((people_ahead//20) + 1) + (people_ahead//20)) * 10 And it worked. Actually the task is supposed to be easy, but for me it turned out to be really difficult ☹️
14th Apr 2020, 10:51 AM
Shamil Erkenov
Shamil Erkenov - avatar
0
After drawing the situation (it's easier for me to understand) I found next logic: 20 = 3 30 = 3 40 = 5 50 = 5 60 = 7 70= 7 80 = 9 And so on... where the number before equal mark is amount of people, the number after is how many times will be necessary to go forward and back before I am able to get on the boat So I wrote the next code, which still fails: import sys people_ahead = int(input()) one_way = 10 if people_ahead < 20: print (one_way) sys.exit() if int(str(people_ahead)[0])%2==0: output = ((people_ahead//10)*10)+10 else: output = (people_ahead//10)*10 print(output) I need another hint🙉😅
13th Apr 2020, 8:29 PM
Shamil Erkenov
Shamil Erkenov - avatar