%I #24 Jan 31 2024 22:23:37
%S 1,1,1,1,1,1,1,1,2,1,1,1,3,1,1,1,1,4,2,1,1,1,1,5,2,1,1,1,1,1,6,3,2,1,
%T 1,1,1,1,7,3,2,1,1,1,1,1,1,8,4,2,2,1,1,1,1,1,1,9,4,3,2,1,1,1,1,1,1,1,
%U 10,5,3,2,2,1,1,1,1,1,1,1,11,5,3,2,2,1,1,1,1,1,1
%N Triangle read by rows. Number of self-measuring subsets of the initial segment of the natural numbers strictly below n and cardinality k. Number of subsets S of [n] with S = distset(S) and |S| = k.
%C We use the notation [n] = {0, 1, ..., n-1}. If S is a subset of [n] then we define the distset of S (set of distances of S) as {|x - y|: x, y in S}. We call a subset S of the natural numbers self-measuring if and only if S = distset(S).
%H Winston de Greef, <a href="/A350103/b350103.txt">Table of n, a(n) of the first 150 rows, flattened (n = 0..11324)</a>
%H Peter Luschny, <a href="/A350102/a350102.png">Illustrating self-measuring subsets of {0, 1, 2, 3}</a>.
%F T(n, k) = floor((n - 1) / (k - 1)) for k >= 2.
%F T(n, k) = 1 if k = 0 or k = 1 or n >= k >= floor((n + 1)/2).
%e Triangle starts:
%e [ 0] [1]
%e [ 1] [1, 1]
%e [ 2] [1, 1, 1]
%e [ 3] [1, 1, 2, 1]
%e [ 4] [1, 1, 3, 1, 1]
%e [ 5] [1, 1, 4, 2, 1, 1]
%e [ 6] [1, 1, 5, 2, 1, 1, 1]
%e [ 7] [1, 1, 6, 3, 2, 1, 1, 1]
%e [ 8] [1, 1, 7, 3, 2, 1, 1, 1, 1]
%e [ 9] [1, 1, 8, 4, 2, 2, 1, 1, 1, 1]
%e [10] [1, 1, 9, 4, 3, 2, 1, 1, 1, 1, 1]
%e [11] [1, 1, 10, 5, 3, 2, 2, 1, 1, 1, 1, 1]
%e [12] [1, 1, 11, 5, 3, 2, 2, 1, 1, 1, 1, 1, 1]
%e .
%e The first column is 1,1,... because {} = distset({}) and |{}| = 0.
%e The second column is 1,1,... because {0} = distset({0}) and |{0}| = 1.
%e The third column is n-1 because {0, j} = distset({0, j}) and |{0, j}| = 2 for j = 1..n - 1.
%e The main diagonal is 1,1,... because [n] = distset([n]) and |[n]| = n (these are the complete rulers A103295).
%p T := (n, k) -> ifelse(k < 2, 1, floor((n - 1) / (k - 1))):
%p seq(print(seq(T(n, k), k = 0..n)), n = 0..12);
%t distSet[s_] := Union[Map[Abs[Differences[#][[1]]] &, Union[Sort /@ Tuples[s, 2]]]]; T[n_, k_] := Count[Subsets[Range[0, n - 1]], _?((ds = distSet[#]) == # && Length[ds] == k &)]; Table[T[n, k], {n, 0, 12}, {k, 0, n}] // Flatten (* _Amiram Eldar_, Dec 16 2021 *)
%o (SageMath) # generating and counting (slow)
%o def isSelfMeasuring(R):
%o S, L = Set([]), len(R)
%o R = Set([r - 1 for r in R])
%o for i in range(L):
%o for j in (0..i):
%o S = S.union(Set([abs(R[i] - R[i - j])]))
%o return R == S
%o def A349976row(n):
%o counter = [0] * (n + 1)
%o for S in Subsets(n):
%o if isSelfMeasuring(S): counter[len(S)] += 1
%o return counter
%o for n in range(10): print(A349976row(n))
%o (PARI) T(n, k) = if(k<=1, 1, (n - 1) \ (k - 1)) \\ _Winston de Greef_, Jan 31 2024
%Y Cf. A350102 (row sums), A349976, A103295, A003988, A010766, A123706.
%K nonn,tabl
%O 0,9
%A _Peter Luschny_, Dec 14 2021