List 1: Write down the numbers 1 to 99
1, 2, 3, 4, 5, 6, 7, 8, 9, ..., 99
List 2: Take every successive set of three numbers (3k-2, 3k-1, 3k) for k=(1...33) and randomly apply a permutation to the trio. Example:
3, 1, 2, 4, 5, 6, 7, 9, 8, ..., 98
List 3: Multiply the first numbers, second numbers, etc of lists 1 and 2. Example:
3, 2, 6, 16, 25, 36, 49, 72, 72, ..., 9702
What is the expected sum of the values in list 3?
328284
Method, define a function of n that computes the expected value for the appropriate trio.
It turns out, this is equivalent to 27n^2 - 18n + 3
The sum of this formula applied to all integers from 1 to n:
27n(n+1)(2n+1)/6 - 18n(n+1)/2 + 3n, which simplifies to
(18n^3 + 9n^2 - 3n)/2
which also is 328284 when n=33
[12, 75, 192, 363, 588, 867, 1200, 1587, 2028, 2523, 3072, 3675, 4332, 5043, 5808, 6627, 7500, 8427, 9408, 10443, 11532, 12675, 13872, 15123, 16428, 17787, 19200, 20667, 22188, 23763, 25392, 27075, 28812]
------
from itertools import permutations
def jumb(n):
x = [3*n-2, 3*n-1, 3*n]
mysum = 0
for perm in permutations(x):
for i,p in enumerate(perm):
mysum += x[i] * p
return int(mysum/6)
bigsum = 0
ans1 = []
ans2 = []
for i in range(1,34):
ans1.append(jumb(i))
ans2.append(27*i**2 - 18*i + 3)
bigsum += jumb(i)
print(bigsum)
print('Does formula give the same answer?', ans1 == ans2)
|
Posted by Larry
on 2024-09-27 10:01:46 |