cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A335009 Irregular triangle read by rows: T(n,k) is the number of permutations of two copies of 1..n with the sum of the distances between equal numbers having total value n + 2*k, 0 <= k <= n*(n-1)/2.

Original entry on oeis.org

1, 2, 4, 6, 24, 24, 36, 24, 144, 288, 480, 576, 432, 576, 120, 960, 2880, 6000, 10560, 12960, 18720, 18000, 17280, 11520, 14400, 720, 7200, 28800, 74880, 161280, 269280, 423360, 596160, 725760, 876960, 915840, 967680, 794880, 691200, 432000, 518400
Offset: 1

Views

Author

Sen-peng Eu, May 19 2020

Keywords

Comments

For the n-th row, the least possible sum of distances is n and the corresponding number of permutations is n!.
For the n-th row, the greatest possible sum of distances is n^2 and the corresponding number of permutations is (n!)^2.

Examples

			For the 6 permutations of [1,1,2,2], there are 2 with total distance 2: [1,1,2,2] and [2,2,1,1]. the other 4 have total distances 4. Hence row 2 of the triangle is 2, 4.
For [1,1,2,2,3,3], there are 6, 24, 24, 36 permutations having total distances 3, 5, 7, 9 respectively. Hence row 3 of the triangle is 6, 24, 24, 36.
Triangle begins:
   1;
   2,   4;
   6,  24,  24,  36;
  24, 144, 288, 480, 576, 432, 576;
  ...
		

Crossrefs

Cf. A000142 (1st column), A001044 (right diagonal), A000124 (row sizes).

Programs

  • Mathematica
    totD[w_] := -Sum[ Subtract @@ Flatten@ Position[w, k], {k, Length[w]/2}]; row[n_] := Last /@ Tally@ Sort[totD /@ Permutations[ Flatten[ Table[{i, i}, {i, n}]]]]; Flatten[row /@ Range[5]] (* Giovanni Resta, May 19 2020 *)
  • PARI
    Row(n)={my(v=vector(1+n*(n-1)/2)); forperm(vector(2*n,i,(i+1)\2), p, my(u=vecsort(Vec(p), ,1), s=sum(i=1, n, abs(u[2*i]-u[2*i-1]-1))); v[1+s/2]++); v} \\ Andrew Howroyd, Aug 11 2020

Formula

T(n,0) = n!.
T(n,n*(n-1)/2) = n!^2.

Extensions

More terms from Giovanni Resta, May 19 2020