What is wrong with my code coach solution? | SoloLearn: Learn to code for FREE!

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 }

5/27/2020 10:24:12 PM

Korijn Jagersma

4 Answers

New Answer

+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.

+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?

+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!

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.