Skip to content

Instantly share code, notes, and snippets.

@AppleCEO
Created January 15, 2020 14:27
Show Gist options
  • Select an option

  • Save AppleCEO/9233c720e7fd3def7b5b7306c1adacc2 to your computer and use it in GitHub Desktop.

Select an option

Save AppleCEO/9233c720e7fd3def7b5b7306c1adacc2 to your computer and use it in GitHub Desktop.
func solution(_ x:Int) -> Bool {
let sum = String(x).reduce(0) { (result, character) -> Int in
result + (Int(String(character)) ?? 0)
}
return x % sum == 0
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment