+ 1

Land ho

I have been working on this question for awhile. I am over thinking it. I know that for 20 and under its 10 and over 20 the wait goes up by 20 and up by 10 before the next digit divisible by 20. What am I doing wrong? https://code.sololearn.com/cEBEt4vJ03aT/?ref=app The challenge, Land Ho! 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 My attempt: import math people = int(input()) if people <= 20: time = 10 print(time) elif people >= 20 and people < 41: time = 30 print(time) elif people > 41: if people > people % 20 and people >= 41: time = people * 2 time = time / 2 + 10 print(round(int(time), -1)) elif people < people % 20 and people >= 41: time = people * 2 time = time / 2 + 10 print(round(int(time), -1))

6th Aug 2020, 2:46 PM
Roland Priske
Roland Priske - avatar
14 ответов
+ 3
this is my solution: You have to wait 10 minutes in every case, because of this is the time it needs to arrive the beach from the ship. Then you have to wait 20 minutes as long as there are more than 20 people are in front of you. Evertime 20 people of them go on the ship, you have to wait for 20 minutes. So this should calculate the time you have to wait: people_ahead = int(input()) waiting_time = 10 while people_ahead >= 20: waiting_time += 20 people_ahead -= 20 print(waiting_time)
2nd Apr 2022, 11:05 AM
David Lau
David Lau - avatar
+ 1
Can you possibly share the whole task with us? Sadly,we are not pro.
6th Aug 2020, 2:54 PM
Baratov Hojiakbar
Baratov Hojiakbar - avatar
+ 1
nope, 80 is suppose to return 90
6th Aug 2020, 3:37 PM
Roland Priske
Roland Priske - avatar
+ 1
Roland Priske Sorry. I can't even imagine unless i see it myself.
6th Aug 2020, 4:09 PM
Baratov Hojiakbar
Baratov Hojiakbar - avatar
+ 1
its alright, in time i will figure it out. i have some new ideas and i did learn about the variations over 100. so i thank you because now i am several steps closer to solving the problem then before
6th Aug 2020, 4:17 PM
Roland Priske
Roland Priske - avatar
+ 1
I'm still not seeing how the correct output for being the 80th person in line is a 90 minute wait time. It should be 70 minutes, surely: First boat, +20 mins wait Second boat, +20 "" Third boat, +20 "" Fourth boat includes me, so +10 mins. Total wait = 70 mins Another reason to question this test: Four of five tests come back correct (for me). How is it possible that only one test comes back wrong?
9th Feb 2022, 6:23 PM
David Casson
David Casson - avatar
+ 1
# 輸入前方人數 p=int(input()) # 自己排在第p+1位,除以20人每趟船班 # 無條件捨去小數位,得到自己的船班次 # 第0班次代表無需等待 n=int((p+1)/20) # 若自己在第1班船,抵達所需時間為10 # 若自己在第2班船,抵達所需時間為10*2*1+10 # 若自己在第3班船,抵達時間為10*2*2+10 # 觀察規律,抵達所需時間為:等候時間+實際搭船時間 # 等候時間為:10*2*班次 # 實際搭船時間:10 print(10*2*n+10) https://code.sololearn.com/cWC4Sp6jAvCd/?ref=app
11th May 2022, 9:26 PM
MING ZI CHEN
MING ZI CHEN - avatar
+ 1
My solution as follows: people = int(input()) time = 0 if people <= 20: time = time + 10 print(time) elif people >= 21: groups = people // 20 time = time + 10 + (20 * groups) print(time) I agree with David's logic here, below is the breakdown of my interpretation of the problem: I think the way they set up the test cases is done in the following way: 1-20 -> 10 minutes waiting time 20+ -> Additional 20 minutes waiting time per group of 20 but when you are dealing with more than 20 the count starts from 1 again as opposed to starting from 21, that way person 80 is waiting 90 minutes whereas that person should have only been waiting 70 minutes.
16th May 2022, 9:13 AM
Adrian
+ 1
line = int(input()) print(int(((line // 20) * 20) + 10)) Hope this helps anyone with the problem.
30th Dec 2022, 11:00 AM
Unknown 1209
Unknown 1209 - avatar
0
2 and its not running, the code we did because at 150 it reads as 250 when it should read as 150. this one is suppose to be easy but its trickier than the password validation challenge. also at 80 it should be 90 but its outputting 40
6th Aug 2020, 4:07 PM
Roland Priske
Roland Priske - avatar
1st Mar 2021, 5:50 AM
Javier Alberto Benitez
Javier Alberto Benitez - avatar
0
import math people = int(input()) p= math.ceil(people/20) if p == 1: print(10) elif p%2 == 0: print((p*10*2)+ 10) else: print((p*10*2) -10)
4th Nov 2022, 9:44 AM
Hamish Zwain
0
I figured it out if the number of people is < 20 time to wait = 10 because 20 is the capacity of the ship + 1 because you one of theme Then if number of people ahead of you is < 20 You gonna add the time for departure of the ship which is 10 mins and arriving the ship 10 mins After the ship arrived you have to add the time for your departure 10 mins It should be (((numberOfPeople / 20) * 20) + 10)
9th Mar 2024, 2:19 PM
Ph Cuber
Ph Cuber - avatar
0
#include <iostream> using namespace std; int main() { int total_number , wait_minut, moving_time=10; cin>>total_number; if(total_number <=20){ wait_minut =10; } if(total_number>20 ){ wait_minut=((total_number/20)*(moving_time*2))+moving_time; } cout<<wait_minut <<endl; return 0; }
9th Jul 2024, 2:14 AM
РАДЖАН ЖУМАНОВИЧ
РАДЖАН ЖУМАНОВИЧ - avatar