CoCalc Shared Files2.2 / Math Research / Mu / muR.ipynbOpen in CoCalc with one click!
Author: Peter Francis
Views : 15
In [13]:
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)
In [20]:
%timeit muR(10,1,3)
10 loops, best of 3: 35.8 ms per loop
In [22]:
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))
In [ ]: