0
Plus help It says there is bug in the code of Popsicles problem "eat them all or give away "
6 Answers
+ 8
Hussin Aourir ,
using a subtraction as done in the code does apply an incorrect logic.
current code ample:
siblings 4 - popsicles 12 is less than 0 (-8)
> but you can share 3 popsicles for each sibling by using *popsicles % siblings ...*
> try to apply a modulo division
the second conditional can be done with *else:*
+ 3
Hi Hussin Aourir in your code you give them away in the case there are as much popsicle as siblings (sib - pop) == 0
The task states to give them away also if they can be equally separated. So with 3 siblings and 6 pops (or 3 to 9, or even 2 to 964 - even it seems like teeth decay sets in) you have to become generous and give them away too. So you need to test if a number leaves a rest in dividing it by another number. You can do this with % operator.
Try to apply it in your code and show your result
+ 2
We cannot help with what we cannot see. Please share your codebit link along with the Lesson number.
+ 1
I fixed it and it works now. Thanks everyone for the help
0
Maybe you share your solution, so others can benifit from it...
Thankyou.