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.
(In reply to
re: Solution by Charlie)
In Python, the itertools library comes included with Python; it is independent of NumPy. Well, included except that you have to add a line of code to import it.
But you're right, there are many functionalities which I feel should be included without the extra step of "importing" them.
For example there is no "sqrt" or value of pi or trig functions unless you first import math:
import math
x = math.sqrt(16)
y = math.pi
z = math.tan(y/x)
But I've never used Matlab, and I don't think it would be free to me.
btw, after I ran the program I made a spreadsheet of 1 to 12 vs 1 to 12, then averaged the differences adjusting the denominator to not include the main diagonal which was all zeros.
|
Posted by Larry
on 2022-12-19 13:01:06 |