I need help on the popsicle challenge. 4/5 right. | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
0

I need help on the popsicle challenge. 4/5 right.

The input is two integers, the first one represents the number of siblings, and the second one represents the number of popsicles. The output should say ā€œgive awayā€ if I can give them away evenly to the siblings, and ā€œeat them to yourselfā€ if I canā€™t give them out evenly. When I put 0 in the input for popsicles it says ā€œgive awayā€ which doesnā€™t make sense because you canā€™t give away 0 popsicles. I donā€™t know how to fix that. https://code.sololearn.com/cK7MRqqLD1wZ/?ref=app

10th Dec 2021, 11:36 PM
Saja
3 Respostas
+ 2
If the number of popsicles doesn't divide equally among the siblings, then eat them yourself otherwise give them away. Basically if 'rem' is not equal to 0 then eat them if it is then give them away. The 1 check in 1 if statement is all you need.
10th Dec 2021, 11:53 PM
ChaoticDawg
ChaoticDawg - avatar
+ 3
ChaoticDawg thank you
11th Dec 2021, 12:02 AM
Saja
+ 1
popsicles%siblings==0
20th Dec 2022, 5:09 AM
Cristian Baeza Jimenez
Cristian Baeza Jimenez - avatar