0
Popsicle test - all clear except test case 5, which I can't view
I don't have premium. Here's my code, what could I be missing? siblings = int(input()) popsicles = int(input()) #your code goes here if (popsicles/siblings) %2 == 0: print("give away") elif (popsicles/siblings) == 0: print("give away") else: print("eat them yourself")
7 Antworten
+ 5
I think you can simplify the code by using
popsicles % siblings
If there are 0 remaining, you can give them away. If it is any other number remaining, you keep them for yourself.
+ 3
If input is
5
15
Then should output "give away". You can give 3 popsicles to each sibling.. 5*3=15 => 15%5==0
+ 2
Mc Rey Pangandoyon Quiao
Please do not give ready-made code. Rather help the OP to find their own solution.
+ 1
Side note, the original logic wasn't just excessively complicated, it flat out didn't work.
Even ignoring the problems caused by integer division (which are always numerous), 15 popsicles for 5 siblings (or any other situation with an odd multiple) would tell you to eat them yourself.
In fact though, performing integer division specifically eliminates the remainder, so even with otherwise good logic it would tell you to always share (which isn't the worst idea in practice lol)
0
Apparently! I didn't do anything to cause this, just copy-pasted
0
Iam also bro same copy paster
0
Ahah, that makes sense! Thanks!