Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
| Download
Project: Peter's Files
Views: 55
Visibility: Unlisted (only visible to those who know the link)
Kernel: SageMath (stable)
from itertools import combinations def sumsetR(H,A, n): SS = set() for m in H: for i in combinations(A, m): SS = SS.union({sum(i) % n}) return SS def Z(n): return set([0..n-1]) def muR(n,k,l): for m in [0..n]: for A in combinations(Z(n),n-m): if sumsetR([k],A,n).intersection(sumsetR([l],A,n)) == set(): return (n-m, A)
%timeit muR(10,1,3)
10 loops, best of 3: 35.8 ms per loop
for i in [1..7]: print(muR(7,i,1))
(0, ()) (3, (1, 2, 4)) (3, (0, 1, 2)) (4, (0, 1, 2, 3)) (5, (0, 1, 2, 3, 5)) (6, (1, 2, 3, 4, 5, 6)) (6, (0, 1, 2, 3, 4, 5))