Visibility: Unlisted (only visible to those who know the link)
Kernel: SageMath (stable)
In [98]:
defsumsetR(H,A):ifmax(H)>len(A):# Error checkingreturn"The maximum subset size of A is greater than the number of elements in A."else:SS=set([])# establish sumsetforminH:# loop through every element in Hlist=Subsets(A,m).list()# list of every m\in H subset of Aforiin[0..len(list)-1]:# loop though element of the above listSS=SS.union({sum(list[i])})# add the sum of each element to the sumsetreturnSS