|
Gentle People, For Checkpoint 5, I imagined this:
No muss, no fuss. Just give the function your collection of numbers, and the function will tell you which of them are winning numbers, if any. Here's what I've got:
My questions are:
I sincerely apologise if I've asked too many questions and for taking more of your time -- I just really want to understand this, foundationally. I'm looking forward to any and all your amazing replies. Thank you very much :) PS: I know I am adding slightly more functionality to this code than the scope of Checkpoint 5. My objective is to first do exactly what Paul said within the confinements he set, and then build my small bit of 'extra' on top of it. In other words, I definitely want my function to work this way for the 'end user', provided I completely understand where Paul was coming from with his rules for Checkpoint 5, and what he wanted of us as coders. |
|
Looks good to me. I'd probably swap the
Not sure what you mean by "without destroying the original input". It's not destroyed, it's still there. There's no good way to do it without using any variables if you want the "None of your numbers will win" message, but otherwise you could do this:
And, really, in this case the
Clarity and ease of reading. Also, To quote from the Swift forum thread where the pitch for
Next question...
Sure.
You're good. Although as I mentioned above I'd probably swap the
When Paul said to use
Your code looks okay. Changes I'd suggest:
|
|
Thank you for your response :) Just one follow up:
Could you please show me how exactly he meant for us to do this? |
|
Exactly like you did it here:
In this case, your |
SPONSORED Still waiting on your CI build? Speed it up ~3x with Blaze - change one line, pay less, keep your existing GitHub workflows. First 25 HWS readers to use code HACKING at checkout get 50% off the first year. Try it now for free!
Sponsor Hacking with Swift and reach the world's largest Swift community!
This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.
All interactions here are governed by our code of conduct.
Link copied to your pasteboard.