What is the maximum value of $f(… f(f(f(x_{1} – x_{2}) – x_{3})-x_{4}) … – x_{2012})$ where $x_{1}, x_{2}, … , x_{2012}$ are distinct integers in the set ${1, 2, 3, …, 2012}$ and $f$ is the absolute value function?
|
|
I am solving with respect to the general case that is $$\max_{\substack{ {x_i\in\{1,2,...,n\}\\ x_i\ne x_j,\ i\ne j}}} f(… f(f(f(x_{1} – x_{2}) – x_{3})-x_{4}) … – x_{n}), \quad f(x)=|x|$$ Since we are looking for a maximum solution, then it is sufficient to distribute the numbers $$1,2,3,...,n$$ in an order so that we get a maximum value for any value of $n$ and that order is what I explained below. Consider the case where $\forall k=1,2,\ ...,\ n-1$ we have $x_k=n-k$ and $x_n=n$ i.e $x_1=n-1$, $x_2=n-2$, $x_3=n-3$ $ , ..., $ $x_k=n-k$ $, ...,$ $ x_{n-1}=1$ but $x_n=n$. So that for $n=8$ for example, we compute the value of $f(f(f(f(f(f(f(7-6)-5)-4)-3)-2)-1)-8)$ Let $f_1=x_1$, $f_2=(x_{1} – x_{2})$, $f_3=(f(x_{1} – x_{2}) – x_{3})$, $...,$ $f_{n }=f(… f(f(f(x_{1} – x_{2}) – x_{3})-x_{4}) … – x_{n})$ Using the following notation where $0\le n_4,k_4\le3$ $$\quad\quad \quad\quad\quad n\equiv n_4 \mod 4 \quad\quad\quad\text { and }$$ $$k \equiv k_4 \mod 4$$ we have the following pattern depending on the value of $n$ (it's preferable to work out some cases to verify what I wrote below). $$\boxed{\begin{array}{ll} f_1=n-1\\ f_2=1 \\ f_3=n- 4 \\ f_4=0 \end{array}} $$ $$ \boxed{f_{n-k}=\left\{\begin{array}{ll}1 \quad \quad \quad \quad \quad \quad\text { if } (n_4,k_4)=\{(0,2),(1,3),(2,0),(3,1)\} \\0 \quad \quad \quad \quad \quad \quad\text { if } n_4=k_4\\f_{n-k-4}+4 \end{array}\right.}$$ $$ \boxed{\begin{array}{ll}f_{n- 4 }=\left\{\begin{array}{ll}0 \quad\text { if } n_4= 0 \quad \\4 \quad\text { if } n_4= 1 \quad \\1 \quad\text { if } n_4= 2 \quad \\3 \quad\text { if } n_4= 3 \quad \end{array}\right.\\f_{n-3}=\left\{\begin{array}{ll}3 \quad\text { if } n_4= 0 \quad \\1 \quad\text { if } n_4= 1 \quad \\2 \quad\text { if } n_4= 2 \quad \\0 \quad\text { if } n_4= 3 \quad \end{array}\right.\\ f_{n-2}=\left\{\begin{array}{ll}1 \quad\text { if } n_4= 0,1 \\0 \quad\text { if } n_4= 2 \quad \\2 \quad\text { if } n_4= 3 \quad \end{array}\right.\\ f_{n-1}=\left\{\begin{array}{ll}0 \quad\text { if } n_4= 0,1 \\1 \quad\text { if } n_4= 2,3 \end{array}\right.\end{array}}$$ And lastly $$f_n=|f_{n-1}-x_n| = |f_{n-1}-n|=\left\{\begin{array}{ll}n&\text { if } n_4= 0,1 \\n-1&\text { if } n_4= 2,3 \end{array}\right.$$ $$2012\equiv 0 \mod 4 \quad \implies \quad f_{2012}=2012$$ |
|||||||||
|
|
I don’t know the answer, but I wrote some code that might help. My code is too slow to calculate the actual answer, with $2012$ in the problem. But if you replace $2012$ with the numbers $1$ through $10$, the answers to those 10 problems are This CoffeeScript code calculates the answer with brute-force, trying all possible permutations and recording the maximum value. One function it provides is Here is the code. You can run it from this JS Bin. Scroll to the “useful calculations” section at the bottom and change the numbers if you want to experiment.
|
||||
|
|