We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Between Two Sets
Between Two Sets
Sort by
recency
|
2947 Discussions
|
Please Login in order to post a comment
Java
Python
JavaScript
def getTotalX(a, b): # Write your code here max_num = min(b) # as the number has to be a factor of all numbers in b, it can't be greater than any of the numbers in list b. min_num = max(a) # as every number in list a is a factor the number should be greater than every number in list a. result_set = set() for i in range(min_num, max_num+1): r_a = map(lambda x: i % x == 0, a) if all(r_a): r_b = map(lambda x: x % i == 0, b) if all(r_b): result_set.add(i) return len(result_set)