Skip to content

Instantly share code, notes, and snippets.

@MarcJacques
Created August 14, 2019 15:34
Show Gist options
  • Select an option

  • Save MarcJacques/b4852bae5f78e972a93eb3013372c7fd to your computer and use it in GitHub Desktop.

Select an option

Save MarcJacques/b4852bae5f78e972a93eb3013372c7fd to your computer and use it in GitHub Desktop.
Code Challenge #2
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