A382528 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-down dealing is used, then the resulting cards will be dealt in increasing order.
1, 2, 1, 3, 1, 2, 3, 1, 2, 4, 4, 1, 2, 5, 3, 6, 1, 2, 5, 3, 4, 5, 1, 2, 6, 3, 4, 7, 6, 1, 2, 8, 3, 4, 7, 5, 9, 1, 2, 7, 3, 4, 8, 5, 6, 7, 1, 2, 8, 3, 4, 10, 5, 6, 9, 8, 1, 2, 11, 3, 4, 9, 5, 6, 10, 7, 11, 1, 2, 9, 3, 4, 10, 5, 6, 12, 7, 8, 9, 1, 2, 10, 3, 4, 13, 5, 6, 11, 7, 8, 12
Offset: 1
Examples
Consider a deck of four cards arranged in the order 3,1,2,4. Card 3 goes under, then card 1 is dealt, then card 2 is dealt, then card 4 goes under, then cards 3 and 4 are dealt. Thus, the fourth row of the triangle is 3,1,2,4. Table begins: 1; 2, 1; 3, 1, 2; 3, 1, 2, 4; 4, 1, 2, 5, 3; 6, 1, 2, 5, 3, 4; 5, 1, 2, 6, 3, 4, 7; 6, 1, 2, 8, 3, 4, 7, 5;
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 DDU(n): return [0] + [(i)%2 for i in range(n)] def DUD(n): return DDU(n+1)[1:] def UDD(n): return DUD(n+1)[1:] seq = [] for i in range(1,10): seq += T(i, UDD(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%len(J) if len(J) > 1: out.append(J.pop(i)) 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, Apr 28 2025
Formula
T(n,k) = T(n-2,k-3) + 2. T(1,1) = 1. For the first 3 columns, we have T(n,1) = T(n-2,n-2) + 2, T(n,2) = 1, and T(n,3) = 2.
It follows that T(n,3k+2) = 2k+1, T(n,3k) = 2k.
Comments