This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
extension Set { | |
mutating func nonUpdatingInsert(member: Element) { | |
if !self.contains(member) { | |
self.insert(member) | |
} | |
} | |