Skip to content

Instantly share code, notes, and snippets.

@sjchmiela
Created January 7, 2016 14:50
Show Gist options
  • Save sjchmiela/2dc9b2765bb9868b5f6f to your computer and use it in GitHub Desktop.
Save sjchmiela/2dc9b2765bb9868b5f6f to your computer and use it in GitHub Desktop.
func customSubsetMinus(A A: [Int], B: [Int]) -> [Int] {
var subset = [Int]()
for a in A {
let occurrences = B.reduce(0, combine: {
(sum, b) -> Int in
return sum + Int(a == b)
})
if occurrences < 2 {
subset.append(a)
}
}
return subset
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment