2

Ayman writes down the numbers 1 through 10 in a sequence in some order, writes down the nine (positive) differences between adjacent numbers and computes the sum of these differences. The result is called the dynamic of the sequence. For example, the dynamic of the sequence 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 is 9, and the dynamic of the sequence 2, 1, 3, 10, 4, 5, 9, 6, 8, 7 is 1 + 2 + 7 + 6 + 1 + 4 + 3 + 2 + 1 = 27. What is the greatest dynamic that such a sequence with the numbers 1 through 10 can have?

my thinking:

To make every single difference as large as possible, you want each step to jump between the smallest and largest unused numbers. A natural way to do that is to alternate low–high–low–high: 1,10,2,9,3,8,4,7,5,6 but i don't know how to prove this strictly

RobPratt
  • 50,938
  • Your sorting is not optimal (but I don't know whether I've found the optimal arrangement). It may be useful to exhaustively check the possibilities for smaller sequences to look for an optimal pattern. – Dermot Craddock Jun 14 '25 at 18:49
  • 1
    This? – https://math.stackexchange.com/q/612553/42969 – Martin R Jun 14 '25 at 18:49
  • 1
    I think I asked a generalised version of this question 3 or 4 years ago. This one: https://math.stackexchange.com/questions/4372504/find-a-permutation-x-sigma1-ldots-x-sigman-of-x-1-ldots-x-n-that – Adam Rubinson Jun 14 '25 at 18:58
  • One reason that won't give a maximum is to just rotate one: $$6,1,10,2,9,3,8,4,7,5$$ gives you a better result, removing $5,6$ and adding $6,1.$ – Thomas Andrews Jun 14 '25 at 18:58
  • 1
    @ThomasAndrews and that is one of the $2\times 4! \times 4!=1152$ optimal permutations. Start with $6$ and "go below $5$ and then above $6$" four times and end with $5$, or reverse this. – Henry Jun 14 '25 at 19:05
  • @Henry that was going to be my guess, but I didn't have much faith in it. – Thomas Andrews Jun 14 '25 at 19:06
  • 2
    @ThomasAndrews I checked all $10!$ possibilities – Henry Jun 14 '25 at 19:10
  • 1
    @henry $1152=2\cdot4!^2,$ and you can get from my answer to any other by permuting the two sets ${1,2,3,4}$ and ${7,8,9,10}$ from my solution and then, optionally, reverse it to start $5$ and end in $6$ instead. So that's then the best you can do: Start and end with $5,6$ and then alternative between the sets ${1,2,3,4,5}$ and ${6,7,8,9,10}.$ I don't see how to prove that, though. – Thomas Andrews Jun 14 '25 at 19:15
  • I suspect proving that is done by taking any permutation that doesn't follow this rule and improving it with a switch of values. – Thomas Andrews Jun 14 '25 at 19:31
  • 1
    @ThomasAndrews I suspect the proof is easier by having a calculation of an upper bound based on alternating across the median. – Henry Jun 14 '25 at 21:01

1 Answers1

2

Here is a more general argument for a permutation $x_1,x_2,x_3, \ldots, x_n$ for any $n$ values with a median $m$.

  • Consider initially a different question, adjusting the permutation slightly by including the first number to appear again after the last number, and then insert $m$ between each pair so we now have $x_1,m,x_2,m,x_3,m, \ldots, m,x_n,m, x_1$. Clearly the sum of absolute differences here is going to be $2 \sum\limits_{i=1}^n |x_i-m|$ and this does not depend on the order in which the $x_i$ appear.

  • But this sum will reduce if we remove the $m$s if there are any cases where $x_i$ and $x_{i+1}$ are both strictly the same side of $m$ (treating $x_{n+1}$ as $x_1$), though not otherwise.

  • So the sum of absolute differences of $x_1,x_2,x_3, \ldots, x_n, x_1$ will also be $2 \sum\limits_{i=1}^n |x_i-m|$ provided that for odd $i$ you have $x_i \le m$ and for the even $i$ you have $x_i\ge m$ or the other way round (if $n$ is odd then it help having $x_1$ or $x_n$ equal to $m$). In other words, $2 \sum\limits_{i=1}^n |x_i-m|$ is an upper bound when $x_1$ appears at the end, achievable if alternating across the median.

  • If we now remove the introduced final $x_1$ then $$\left(2 \sum\limits_{i=1}^n |x_i-m|\right) -|x_n-x_1|$$ is an upper bound for the sum of absolute differences of $x_1,x_2,x_3, \ldots, x_n$. If we can satisfy the alternating condition for $2 \sum\limits_{i=1}^n |x_i-m|$ and at the same time minimise the $|x_n-x_1|$ term then we have an optimal permutation.

In this particular question, $n=10$ and the median of $x_1,x_2,x_3, \ldots, x_{10}$ is between $5$ and $6$, say $5.5$, giving us an upper bound of the sum of absolute differences of $50-|x_{10}-x_{1}|$ and, since each term is different meaning $|x_{10}-x_{1}|\ge 1$, a optimal permutation cannot give more than $50-1=49$.

This $49$ is achievable with $6,1,10,2,9,3,8,4,7,5$ or any other permutation which alternates above and below the median and has starting and ending points which differ by $1$ (i.e. a start of $5$ and end of $6$, or start of $6$ and end of $5$). There are $2\times 4! \times 4!=1152$ permutations of $1,2,3,\ldots, 10$ which meet these constraints.

Henry
  • 169,616