You are viewing a single comment's thread. Return to all comments →
This is a great solution. I implemented it in Swift
func getTotalX(a: [Int], b: [Int]) -> Int { var allElementsAreMultiple = false var numberIsMultipleOfAll = false let minB = b.reduce(b[0], min) var total = 0 for i in 1...minB { allElementsAreMultiple = a.map { return i % $0 == 0 }.reduce(true, {$0 && $1}) numberIsMultipleOfAll = b.map { return $0 % i == 0 }.reduce(true, {$0 && $1}) if (allElementsAreMultiple && numberIsMultipleOfAll) { total += 1 } } return total }
Seems like cookies are disabled on this browser, please enable them to open this website
Between Two Sets
You are viewing a single comment's thread. Return to all comments →
This is a great solution. I implemented it in Swift