+ 1

Questions

https://www.sololearn.com/coach/4?ref=app Guys can you explain me this problem then onky I can make code

12th May 2024, 4:06 PM
Raine04
Raine04 - avatar
9 Answers
+ 5
Raine04 , before we can help you, please show us your code try. save the code in playground and post a link to it here.
12th May 2024, 4:09 PM
Lothar
Lothar - avatar
+ 4
It is the code coach "Halloween Candy". It would be easier for us if you mention the code coach question name, because AFAIK not all devices can open the link you post. Back to your question, how about working backward and analysis the logic behind the question? Out of 5 test cases, 2 are viewable. Case 1: >> input = 3, output = 67 Case 2: >> input 10, output = 20 As the description says, all but three houses giving out candy. In for those three houses not giving candy, one giving toothbrushes, and two giving dollar bills. The output is a rounded up to the nearest whole number. From Case 1, we visit only 3 houses. Which means one is giving toothbrushes and two are giving $. 2 / 3 = 66.6666% >> rounding up >> 67 (whole number) From Case 2, all but three houses giving out candy >> 7 houses are giving candy, and the remaining 3 houses, one is giving toothbrushes and other two giving dollar bill. 2 / 10 = 20% >> rounding up >> 20 Hope it helps.
13th May 2024, 2:41 AM
Wong Hei Ming
Wong Hei Ming - avatar
+ 4
Lothar, Thanks For Telling Me. I Understood .........
13th May 2024, 10:39 PM
JaiprakashJH
JaiprakashJH - avatar
+ 2
What do you need help with understanding? Maybe take a piece of paper and a pen and write the numbers down, write some test numbers out and check. Then wrote pseudocode. Then code it.
12th May 2024, 8:11 PM
Ausgrindtube
Ausgrindtube - avatar
+ 2
Raine04 "all but" means just a phrase for everything or everyone except for https://dictionary.cambridge.org/dictionary/english/all-but all but three houses -> all houses except three You can also have a look at this page on how to calculate the probability: https://www.mathsisfun.com/data/probability.html Probability of an event happening = Number of ways it can happen / Total number of outcomes In your case: number of houses where you can get money / total number of houses e.g. 2/3 = 0.66667 to get 66.7 % you need to multiply it by 100 and with math.ceil() you round it up to 67 % Btw: I also cleaned up this thread
13th May 2024, 6:21 PM
Denise Roßberg
Denise Roßberg - avatar
0
How
12th May 2024, 8:09 PM
sarah shalom
sarah shalom - avatar
0
Wong hei ming thank-you
13th May 2024, 5:28 AM
Raine04
Raine04 - avatar
0
Actually the doubt was that how many houses are giving candies and how many toothbrush
13th May 2024, 5:28 AM
Raine04
Raine04 - avatar
0
Because it said that all but three houses so I got confused
13th May 2024, 5:29 AM
Raine04
Raine04 - avatar