+ 1
Questions
https://www.sololearn.com/coach/4?ref=app Guys can you explain me this problem then onky I can make code
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.
+ 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.
+ 4
Lothar,
Thanks For Telling Me.
I Understood .........
+ 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.
+ 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
0
How
0
Wong hei ming thank-you
0
Actually the doubt was that how many houses are giving candies and how many toothbrush
0
Because it said that all but three houses so I got confused