+ 1

Could anyone tell me why test case 4 Is showing error in code coach problem named "Land Ho!"???I am not a pro user!

people=int(input()) if people<20: print(10) elif people>=20 and people%10==0: print(people+10) elif people>=20 and people%10!=0: if round(people,-1)<people: print((round(people,-1))+10) else: print(round(people,-1))

20th Mar 2023, 5:39 AM
Vaibhav Pandey
9 Respostas
+ 3
If there are 30 people, then you're saying the wait time is 40 mins?
20th Mar 2023, 6:03 AM
Ausgrindtube
Ausgrindtube - avatar
+ 3
Then your logic is incorrect. First 20 people leave and the boat returns = 20 mins. I can go on the second boat, so I leave with the second group = 10 mins Total = 30 mins
20th Mar 2023, 6:08 AM
Ausgrindtube
Ausgrindtube - avatar
+ 3
The boat can take groups of 20 people. Each group needs to wait 10 minutes to get there. Group 1 [20] = 10 mins Group 2 [40] = 30 mins Group 3 [60] = 50 mins Group n [n*20] = n*20-10mins
20th Mar 2023, 7:27 AM
Ausgrindtube
Ausgrindtube - avatar
+ 3
Well done Vaibhav Pandey I'm happy you got there
20th Mar 2023, 9:47 AM
Ausgrindtube
Ausgrindtube - avatar
+ 1
Vaibhav Pandey , I'm write this code very simple: people=int(input()) if people <=20: print(10) else: wait=(people//20)*20+10 print(wait)
21st Mar 2023, 11:35 AM
Galina Van
0
Ausgrindtube yes bro
20th Mar 2023, 6:04 AM
Vaibhav Pandey
0
Ausgrindtube how is this incorrect bro i didn't understand??
20th Mar 2023, 6:11 AM
Vaibhav Pandey
0
Ausgrindtube nah bro u see test case 2 is not matching your code the input in test case 2 is 80 and output is 90 whereas in your code if i input 80 it will be 70.
20th Mar 2023, 7:40 AM
Vaibhav Pandey
0
Ausgrindtube done bro i did it people=int(input()) if people<20: print(10) elif people>=20 and people%20==0: print(people+10) elif people>=20 and people%20!=0 and people%10==0: print(people) elif people>=20 and people%20!=0 and people%10!=0: if round(people,-1)<people and round(people,-1)%20==0: print(round(people,-1)+10) elif round(people,-1)>people and round(people,-1)%20==0: print(round(people,-1)+10) elif round(people,-1)>people and round(people,-1)%20!=0: print(round(people,-1)) elif round(people,-1)<people and round(people,-1)%20!=0: print(round(people,-1))
20th Mar 2023, 8:26 AM
Vaibhav Pandey