Created
August 14, 2019 15:34
-
-
Save MarcJacques/b4852bae5f78e972a93eb3013372c7fd to your computer and use it in GitHub Desktop.
Code Challenge #2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import UIKit | |
| func sumAndProduct(_ sum: UInt,_ product: UInt) -> [UInt] { | |
| let x = sum / 2 | |
| let y = product / x | |
| var solutionArray: [UInt] | |
| if x + y != sum || x * y != product { | |
| solutionArray = [] | |
| } else { | |
| solutionArray = [x, y] | |
| } | |
| return solutionArray | |
| } | |
| sumAndProduct(6, 9) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment