Skip to content

Instantly share code, notes, and snippets.

View simonracz's full-sized avatar

Simon Racz simonracz

  • Amsterdam
View GitHub Profile
// Explanation
// 0 1 2 3 4
// 0 | o o o o|
// 1 |o o o o|
// 2 |o o o o|
// 3 |o o o o|
// 4 |o o o o |
//
// Goal is to "sum up" the dots in each columns. (Dot represents a product of course not a sum)
// I do that by first "summing up" the upper triangle, then the lower triangle
@simonracz
simonracz / gist:fa2b9267ce07278d926d
Created January 8, 2016 13:19
Add non-updating insert methods to swift Set
import Foundation
extension Set {
mutating func nonUpdatingInsert(member: Element) {
if !self.contains(member) {
self.insert(member)
}
}