Plus help It says there is bug in the code of Popsicles problem "eat them all or give away " | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Plus help It says there is bug in the code of Popsicles problem "eat them all or give away "

23rd Jan 2023, 12:43 PM
Hussin Aourir
Hussin Aourir - avatar
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:*
23rd Jan 2023, 3:49 PM
Lothar
Lothar - avatar
+ 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
23rd Jan 2023, 3:41 PM
JuZip
+ 2
We cannot help with what we cannot see. Please share your codebit link along with the Lesson number.
23rd Jan 2023, 2:32 PM
Justice
Justice - avatar
23rd Jan 2023, 3:06 PM
Hussin Aourir
Hussin Aourir - avatar
+ 1
I fixed it and it works now. Thanks everyone for the help
23rd Jan 2023, 4:01 PM
Hussin Aourir
Hussin Aourir - avatar
0
Maybe you share your solution, so others can benifit from it... Thankyou.
14th Jan 2024, 4:54 PM
WN Lekx