• + 0 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())