You are viewing a single comment's thread. Return to all comments →
def nonDivisibleSubset(k, s): remainders = Counter([i % k for i in set(s)]) if k/2 in remainders: remainders[k/2] = 1 if 0 in remainders: remainders[0] = 1 even_div = [(x, y) for x, y in (combinations(remainders, 2)) if x + y == k] for i,j in even_div: remainders.pop(i if remainders[i] < remainders[j] else j) return sum(remainders.values())
Seems like cookies are disabled on this browser, please enable them to open this website
Non-Divisible Subset
You are viewing a single comment's thread. Return to all comments →