Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download
Project: Peter's Files
Views: 62
Visibility: Unlisted (only visible to those who know the link)
Kernel: SageMath (stable)
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
def Z(n): return set([0..n-1])
def muR(G, (k,l)): master = Subsets(G).list() return (n,l,k)
muR(1,(40,3))
(1, 40, 3)
sumsetR([2], [1,2,3])
{3, 4, 5}