Skip to content

Instantly share code, notes, and snippets.

@oisdk
Last active August 29, 2015 14:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oisdk/160c9473e9b028efad59 to your computer and use it in GitHub Desktop.
Save oisdk/160c9473e9b028efad59 to your computer and use it in GitHub Desktop.
import Foundation
func listSum(n: Int, tot: Int) ->[Int] {
return n == 1 ? [tot] :
{[$0, tot - $0] + listSum(n - 1, tot - $0)} (Int(arc4random_uniform(UInt32(tot - n))))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment