The following sum is constituted for each permutation p
1, p
2, p
3,..., p
9, p
A, p
B, p
10 of the duodecimal (base 12) integers 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, 10:
|p1-p2|+|p3-p4|+|p5-p6|+|p7-p8|+|p9-pA|+|pB-p10|
Determine the average value of all such sums.
I came to the same realization as Charlie that the sum is just six times the average value of a single difference. But using a computer program to calculate that is massive overkill.
We can see from the 12 consecutive numbers there are 11 pairs that differ by 1, 10 pairs that differ by 2, 9 pairs that differ by 3, ... all the way down to one pair that differs by 11.
So we have 11+10+9+...+1=66 pairs, whose sum of differences is 11*1+10*2+9*3+...+1*11=286. Then the answer to the problem is (286/66)*6=26. Or 22 in base 12 if we wish to keep to the duodecimal representation.
This is very easily generalizable. Lets take every permutation of the numbers 1 to 2n and calculate the average of |p_1 - p_2|+|p_3 - p_4|+...+|p_2n-1 - p_n|.
This will be n times the average value for |p_x - p_y|.
There will be (2n-1)+(2n-2)+...+1 = 2n*(2n-1)/2 pairs (2n-1_th triangular number).
The total of the differences will be (2n-1)*1 + (2n-2)*2 + (2n-3)*3 + ... + 1*(2n-1) = (2n-1)*2n*(2n+1)/6 (alternate summation of the 2n-1_th tetrahedral number).
Then the answer to the generalized problem is n*[(2n-1)*2n*(2n+1)/6]/[2n*(2n-1)/2] = n*(2n+1)/3. This value may be recognized as one third of the 2n-th triangular number The original problem is the n=6 case of the generalized problem, which checks as 6*(2*6+1)/3 = 26.