A382354 Triangle T(n,k) read by rows, where row n is a permutation of the numbers 1 through n, such that if a deck of n cards is prepared in this order, and under-down-under dealing is used, then the resulting cards will be dealt in increasing order.
1, 2, 1, 3, 1, 2, 2, 1, 3, 4, 4, 1, 5, 3, 2, 4, 1, 3, 5, 2, 6, 3, 1, 7, 5, 2, 4, 6, 5, 1, 7, 4, 2, 8, 6, 3, 7, 1, 4, 6, 2, 8, 5, 3, 9, 4, 1, 10, 8, 2, 5, 7, 3, 9, 6, 10, 1, 7, 5, 2, 11, 9, 3, 6, 8, 4, 9, 1, 5, 11, 2, 8, 6, 3, 12, 10, 4, 7, 5, 1, 8, 10, 2, 6, 12, 3, 9, 7, 4, 13, 11
Offset: 1
Examples
Consider a deck of four cards arranged in the order 2,1,3,4. Card 2 goes under, card 1 is dealt, and card 3 goes under. After the first round, the deck is ordered 4,2,3. Now, card 4 goes under, and card 2 is dealt, and card 3 goes under. After the second round, the deck is ordered 4,3. Now card 4 goes under, and card 3 is dealt. In the last round, card 4 is dealt. The dealt cards are in order. Thus, the fourth row of the triangle is 2,1,3,4. Table begins: 1; 2, 1; 3, 1, 2; 2, 1, 3, 4; 4, 1, 5, 3, 2; 4, 1, 3, 5, 2, 6; 3, 1, 7, 5, 2, 4, 6; 5, 1, 7, 4, 2, 8, 6, 3;
Programs
-
Python
def T(n, A): return invPerm(J(n,A)) def J(n,A): l=[] for i in range(n): l.append(i+1) index = 0 P=[] for i in range(n): index+=A[i] index=index%len(l) P.append(l[index]) l.pop(index) return P def invPerm(p): inv = [] for i in range(len(p)): inv.append(None) for i in range(len(p)): inv[p[i]-1]=i+1 return inv def UDU(n): return [1] + [2 for i in range(n)] seq = [] for i in range(20): seq += T(i,UDU(i)) print(", ".join([str(v) for v in seq]))
-
Python
def row(n): i, J, out = 0, list(range(1, n+1)), [] while len(J) > 1: i = (i + 1)%len(J) out.append(J.pop(i)) i = (i + 1)%len(J) out += [J[0]] return [out.index(j)+1 for j in list(range(1, n+1))] print([e for n in range(1, 14) for e in row(n)]) # Michael S. Branicky, Mar 27 2025
Formula
For any n, we have T(n,2) = 1. T(1,1) = 1; T(2,1) = 2. For n > 2, T(n,1) = T(n-1,n-2) + 1 and T(n,3) = T(n-1,n-1) + 1. For n > 3 and k > 3, T(n,k) = T(n-1,k-3) + 1.
Comments