0

What is wrong with my code coach solution?

•(SORRY FOR THE CAPSLOCK, THIS APP HAS SOME SORT OF BUG IN IT THAT DOESN’T ALLOW ME TO TYPE NORMAL.) I WROTE MY CODE COACH SOLUTION IN SWIFT AND IF I TEST IT THERE’S NO OUTPUT ALTHOUGH I THINK THERE SHOULD BE... CAN YOU NOTICE SOMETHING WRONG? THIS IS MY CODE, [IT IS FOR THE POPSICLES CHALLENGE] func decision(siblings:Int, popsicles:Int) -> String { var choose:String if popsicles%siblings == 0 { choose = "give away" } else { choose = "eat them yourself" } return choose }

27th May 2020, 10:24 PM
Korijn Jagersma
Korijn Jagersma - avatar
4 Answers
+ 4
No, you need to get the input, pass the values to the called function and output the result. Program needs to be written as if you were running it in the playground.
27th May 2020, 11:38 PM
ChaoticDawg
ChaoticDawg - avatar
+ 3
I don't see anywhere in this code where it gets the input or prints the output, just a function to make the decision. There isn't even a call to the function to run it. Is this all your code?
27th May 2020, 11:21 PM
ChaoticDawg
ChaoticDawg - avatar
+ 1
Yes, I could use help here too. I want to start doing the code coach challenges with Swift, but I am in the same boat as Korijn. I don't think either of us understand exactly how the challenge is inputting the values into our code and what kind of code we need to use to get the desired output. An example of one solved in Swift would be extremely helpful for us beginners!
21st Aug 2020, 1:12 PM
Michelle
Michelle - avatar
0
Yes it is, i figured code coach uses the parameters as input and uses the return function as output and then fires the function for each test case.
27th May 2020, 11:36 PM
Korijn Jagersma
Korijn Jagersma - avatar