A329851
Sum of absolute values of n-th differences over all permutations of {0, 1, ..., n}.
Original entry on oeis.org
0, 2, 12, 120, 1320, 17856, 273056, 4772624, 92626944, 1986317024, 46556867456, 1184827221584, 32524270418432, 958020105786536
Offset: 0
For n = 2, the second differences of the (2+1)! = 6 permutations of {0,1,2} are:
[0,1,2] -> [1, 1] -> 0,
[0,2,1] -> [2,-1] -> -3,
[1,0,2] -> [-1, 2] -> 3,
[1,2,0] -> [1,-2] -> -3,
[2,0,1] -> [-2, 1] -> 3, and
[2,1,0] -> [-1,-1] -> 0.
The sum of the absolute values of these second differences is 0 + 3 + 3 + 3 + 3 + 0 = 12.
-
a[n_] := Block[{x, k}, k = CoefficientList[(x - 1)^n, x]; Sum[Abs[k.p], {p, Permutations@ Range[0, n]}]]; Array[a, 10, 0] (* Giovanni Resta, Nov 23 2019 *)
-
from math import comb
from itertools import permutations
def A329851(n):
c = [-comb(n,i) if i&1 else comb(n,i) for i in range(n+1)]
return sum(abs(sum(c[i]*p[i] for i in range(n+1))) for p in permutations(range(n+1)) if p[0]Chai Wah Wu, Jun 04 2024
A373422
Triangle read by rows: T(n,k) = number of permutations of [n] starting from k that have zero (n-1)-th differences. (n>=1, 1<=k<=n).
Original entry on oeis.org
0, 0, 0, 1, 0, 1, 1, 0, 0, 1, 4, 2, 4, 2, 4, 3, 0, 0, 0, 0, 3, 40, 36, 40, 40, 40, 36, 40, 29, 0, 0, 0, 0, 0, 0, 29, 232, 152, 240, 200, 208, 200, 240, 152, 232, 235, 142, 140, 257, 168, 168, 257, 140, 142, 235, 11712, 13216, 12208, 12384, 11408, 11136, 11408, 12384, 12208, 13216, 11712
Offset: 1
T(3,1) = 1 because [1,2,3] have zero 2nd differences.
1 2 3
1 1
0
Triangle starts:
0;
0, 0;
1, 0, 1;
1, 0, 0, 1;
4, 2, 4, 2, 4;
3, 0, 0, 0, 0, 3;
40, 36, 40, 40, 40, 36, 40;
29, 0, 0, 0, 0, 0, 0, 29;
232, 152, 240, 200, 208, 200, 240, 152, 232;
235, 142, 140, 257, 168, 168, 257, 140, 142, 235;
-
tabl(n) = my(nn=vector(n)); forperm([1..n], p, if(sum(k=1, n, (-1)^k*binomial(n-1, k-1)*p[k])==0, nn[p[1]]++)); nn;
A373284
Number of permutations of {1, 2, 3, ..., n} that result in a final value of 0 by repeatedly iterating the process of "subtracting if the next item is greater or equal, otherwise adding" until there's only one number left.
Original entry on oeis.org
0, 0, 1, 1, 3, 10, 52, 459, 1271, 10094, 63133, 547565, 4431517, 42046100, 400782747, 8711476734
Offset: 1
For n=5, one of the a(5) = 3 solutions is (1, 4, 5, 2, 3), whose trajectory to 0 is
1 4 5 2 3
3 1 7 1
4 6 8
2 2
0
-
Block[{fn, cperm, rs}, fn = Function[ls, First @ NestWhile[ MapThread[If[#2 < #1, #1 + #2, #2 - #1] &, {Most@#, Rest@#}] &, ls, Length@# > 1 &]]; cperm = Function[n, Total[ ParallelMap[ Boole[fn@# == 0] &, Permutations @ Range @ n]]]; rs = Table[cperm @ n, {n, 10}]; rs] (* Mikk Heidemaa, Mar 14 2025. Based on the Python code below *)
-
from itertools import permutations
def f(t):
if len(t) == 1: return t[0]
return f([t[i]+t[i+1] if t[i+1]Michael S. Branicky, May 30 2024
Showing 1-3 of 3 results.
Comments