All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars    
perplexus dot info

Home > Numbers
Permuted average (Posted on 2020-09-01) Difficulty: 3 of 5
For each permutation a1, a2, . . . , a10 of the integers 1,2,3,...,10, form the sum |a1 - a2| + |a3 - a4| + |a5 - a6| + |a7 - a8| + |a9 - a10|.

Find the average value of all such sums.

No Solution Yet Submitted by Danish Ahmed Khan    
No Rating

Comments: ( Back to comment list | You must be logged in to post comments.)
Solution computer solution and discussion | Comment 1 of 4
 a$ = "1234567890": h$ = a$
 
 Do
   For i = 1 To Len(a$) - 1 Step 2
     n1 = Val(Mid(a, i, 1)): If n1 = 0 Then n1 = 10
     n2 = Val(Mid(a, i + 1, 1)): If n2 = 0 Then n2 = 10
     tot = tot + Abs(n2 - n1)
     DoEvents
   Next
   DoEvents
   ct = ct + 1
   permute a$
 Loop Until a$ = h$
 Text1.Text = Text1.Text & tot / ct

 Text1.Text = Text1.Text & vbCrLf & " done"
 
(I note that it really wasn't necessary to convert zero to 10, as the differences overall wouldn't be affected--  0 to 9 vs 1 to 10.)

This finds the average as 55/3.

More interesting is the general case, so for even number of elements:

 2   1   =   3/3
 4          10/3
 6   7   =  21/3
 8  12   =  36/3  
10          55/3

It looks like a quadratic and indeed putting 3, 19, 12, 36, 55 into the OEIS, we find n*(2*n + 1) (sequence A014105).

Of course this might be misleading, as it also finds A281153, which continues to match until 11 elements later when an 18 replaces a 528. 

But I'll go with the n*(2*n + 1)/3, where n is the length of the permuted sequence divided by 2. That makes the formula L*(L + 1)/6 where L is the length of the permuted sequence. That's the sum of the numbers from 1 to L divided by 3.

  Posted by Charlie on 2020-09-01 11:00:36
Please log in:
Login:
Password:
Remember me:
Sign up! | Forgot password


Search:
Search body:
Forums (0)
Newest Problems
Random Problem
FAQ | About This Site
Site Statistics
New Comments (0)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

Chatterbox:
Copyright © 2002 - 2024 by Animus Pactum Consulting. All rights reserved. Privacy Information