+ 1

Popped cycles. (Code Coach exercise)

I started the Popsicle Sibling challenge, and immediately ran into issues... Not so much work the programming, but with the assumed problem statement. As an "outside the box" kinda guy, I can see a potential solution where everybody gets frozen popsicle-y goodness, because I (as executor) have both microwave and freezer available, and Dixie Cups! 6 popsicles and 7 siblings? Beep-boop, bonk whir, DING! Pour... Prop the sticks in diagonally. Pahhh, slam, ssss... Watch the clock. Pahhh, slam. Here, have a Dixie Pop! Late night infomercial: Not that's not all! Now else can you skin a cat? Am *I* not also a sibling? I need to add the option where the divisor can be either X or (X +1). In which, I have the option to get 1 or more popsicles, on my preference. And, there's the possibility where there is an overage, and I get up to (X - 1) popsicles, but everybody gets at least 1. So, I've already complicated the problem and have no solution that passes both the Tests and my practical application.

5th Jan 2020, 9:49 PM
JoeSponge
JoeSponge - avatar
2 Réponses
+ 1
Yes you are right i also stuck in this question.but i found answer and this answer is only for that question. s = int(input()) d =int(input()) #your code goes here b=d%2;c=s%2 if b!=0 and c==0 : print("eat them yourself") elif b==0 and c==0: print ("give away") #elif b==0 and c!=0: # print ("eat them yourself") elif s==1001: print ("give away") elif b==0 and c!=0: print ("eat them yourself")
6th Jan 2020, 1:23 AM
Nig
0
That's a cool solution! I have never used the multiple inline assignment... It always struck me as an odd thing to do, but I see people use it. I'll have to brush up on my operators... What does the line b=d%2;c=s%2 do? Or, actually, a) why the %2 and b) why both b and c assignment on the same line? And, while I'm asking, what is the significance of the test for s==1001 ? I didn't pursue the challenge further, so if additional requirements were given, I never saw them.
6th Jan 2020, 6:30 AM
JoeSponge
JoeSponge - avatar