Open with one click!
In [98]:
def sumsetR(H,A): if max(H) > len(A): # Error checking return "The maximum subset size of A is greater than the number of elements in A." else: SS = set([]) # establish sumset for m in H: # loop through every element in H list = Subsets(A, m).list() # list of every m\in H subset of A for i in [0..len(list)-1]: # loop though element of the above list SS = SS.union({sum(list[i])}) # add the sum of each element to the sumset return SS
In [63]:
def Z(n): return set([0..n-1])
In [97]:
def muR(G, (k,l)): master = Subsets(G).list() return (n,l,k)
In [74]:
(1, 40, 3)
In [95]:
sumsetR([2], [1,2,3])
{3, 4, 5}