0

Code Coach SWIFT Input?

Note: I am already aware exactly how the code coach uses output to define answers and all that. Main question: I have come up with a solution that WOULD pass every single test of the “Popsicles” code coach challenge. (Two sets of inputs tested back-to-back, one set solves 3 tests and the other set solves the other 2. My body code is very general and isn’t the issue.) I’m not going to post my methods here because I’ve read elsewhere that it’s against the rules to share answers. Anyways - I just need to know: How do I “get” the “input” sets that are passed by the tests (In Swift) ? I can only manually insert one set or the other in the code portion and there’s no way I know of to make my sibling or popsicle variables based on test input. I’ve tried loops and switch statements but have not succeeded - I still get the output of only one set.

19th Jun 2020, 9:31 PM
Hailey
9 Respostas
+ 3
19th Jun 2020, 11:05 PM
Russ
Russ - avatar
+ 3
Share or Copy the code coach and paste here to help solve u
19th Jun 2020, 10:16 PM
Muhammad Galhoum
Muhammad Galhoum - avatar
+ 3
Code coach itself Leslie Jepsen
19th Jun 2020, 10:34 PM
Muhammad Galhoum
Muhammad Galhoum - avatar
+ 3
I wrote a code in python as i didn't know swift siblings=int(input("please enter the number of siblings")) popsicles=int(input("please enter the number of popsicles")) if popsicles % siblings == 0: print("give away") else: print("eat them") Leslie Jepsen
19th Jun 2020, 10:50 PM
Muhammad Galhoum
Muhammad Galhoum - avatar
+ 3
Yes, values ​​must be entered for Siblings and Popsicles by the user and the user here is an interpreter who enters values ​​from him to make sure the code is correct Leslie Jepsen
19th Jun 2020, 11:02 PM
Muhammad Galhoum
Muhammad Galhoum - avatar
+ 1
Oh, so i’m assuming instead of setting variables directly, I have to get the user’s input for Siblings and Popsicles?
19th Jun 2020, 10:57 PM
Hailey
+ 1
Thank you very much for your help, everyone! 🙂 @Russ Thank you as well for helping me out with finding input. I understand this now.
19th Jun 2020, 11:09 PM
Hailey
0
Sure thing - Do you mean the code coach itself or my code? 🙂
19th Jun 2020, 10:27 PM
Hailey
0
Alrighty! You have a box of popsicles and you want to give them all away to a group of brothers and sisters. If you have enough left in the box to give them each an even amount you should go for it! If not, they will fight over them, and you should eat them yourself later. Task Given the number of siblings that you are giving popsicles to, determine if you can give them each an even amount or if you shouldn't mention the popsicles at all. Input Format Two integer values, the first one represents the number of siblings, and the second one represents the number of popsicles that you have left in the box. Output Format A string that says 'give away' if you are giving them away, or 'eat them yourself' if you will be eating them yourself. Sample Input 3 9 Sample Output give away
19th Jun 2020, 10:38 PM
Hailey