Hi everyone! I recently came across this nice problem, and decided to share it here for others to enjoy. Feel free to post your thoughts and solutions!
When you write the string \(a \leftarrow bc \leftarrow d\) in a text editor (where \(\leftarrow\) denotes the left-arrow key of the keyboard), you get the string \(bdca\). Hence, we can insert arrows within string \(abcd\) in such a way that we get the string \(bdca.\)
Now, consider two strings and . Suppose that you can insert arrows within string to obtain string Show that you can also insert arrows within string to obtain string
Just to clarify, you are allowed to enter multiple arrows before a character. For example, doing (which gives the string ) is allowed. However, you cannot use right arrows.
Here's an example which shows this for the strings and :
As already shown above, we can insert arrows within to obtain . We shall show that we can insert arrows within to obtain This is simple; just do
Also, just to be specific, we're working with strings of any length, not just length , and all characters of the strings are distinct (thanks Daniel).
Source: USA TSTST 2014
This is one of my favorite problems. I've given this to many of my friends (mostly people who qualified RMO but unfortunately failed INMO), and we've gotten many different solutions to this problem. I have a solution which finds a condition for the string to be attainable from a permutation of and then shows that if this condition holds for a permutation, it must also hold for its inverse, completing the proof (I can post it if necessary). A friend of mine has another nicer solution using induction, I can also post that for him if anyone wants.
I'm looking forward to how the people here approach this really nice problem. Thanks for reading this. :)
Easy Math Editor
This discussion board is a place to discuss our Daily Challenges and the math and science related to those challenges. Explanations are more than just a solution — they should explain the steps and thinking strategies that you used to obtain the solution. Comments should further the discussion of math and science.
When posting on Brilliant:
*italics*
or_italics_
**bold**
or__bold__
paragraph 1
paragraph 2
[example link](https://brilliant.org)
> This is a quote
\(
...\)
or\[
...\]
to ensure proper formatting.2 \times 3
2^{34}
a_{i-1}
\frac{2}{3}
\sqrt{2}
\sum_{i=1}^3
\sin \theta
\boxed{123}
Comments
wlog take the initial string Sn as composed of the integer i at each index i. For example, instead of 'abcd' in your example we would call it '1234'. Now, any string obtained from S consists of a permutation on (1, 2, ... n). Call this a1,a2,...an. What strings can NOT be obtained? It is easy to see that the strings which cannot be obtained are precisely those for which we can find three indices i < j < k such that aj<ai<ak. But in this case we can take ai,aj,ak as i,j,k in the operation to see that the inverse of the permutation also satisfies this condition. In other words, if a permutation cannot be obtained from Sn, then neither can its inverse. Therefore, if a permutation CAN be obtained then so can its inverse.
Log in to reply
Yup, that's precisely my solution. Just filling out the details; here's the solution I wrote in the AoPS thread.
WLOG let string A be 1,2,⋯,n, so B is a permutation of 1,2,⋯,n. Let's characterize all permutations from which A is reachable. Consider a permutation b1,b2,⋯,bn of 1,2,⋯,n from which A can be reached.
Define an increasing block starting from bi to be a subset of {b1,b2,⋯,bn} of the form {bi,bi+1,⋯,bi+j}, where bi+k>bi+k−1 for all 1≤k≤j. Also, define the associate of bi to be the largest bj satisfying j<i and bj<bi.
Note that to transform b1,b2,⋯,bn into 1,2,⋯,n, we must add arrows according to the following rules.
Start with b1. Let S1 be the largest increasing block starting from b1. Let bj be the last element of S1. Add a suitable number of arrows to the left of bj+1 such that bj+1 gets placed just to the right of its associate.
Let bi be the element our cursor is currently on. Do the basically same thing with bi: let Si be the largest increasing block starting from bi. Add arrows at the end of its last element so that the element after it gets placed right after its associate.
Keep doing this throughout the whole sequence.
(Just to clarify, the string b1,b2,⋯,bn gets modified after each step accordingly.)
This is the only way we can transform {bi}i=1n to {i}i=1n. To see why this is true, note that after arrows have been placed to the left of some bi, its position can't be changed later, so we must make sure that each element has been placed just to the right of the largest operated element smaller than it (operated in the sense that arrows have been placed to the right of it so its position can't be changed anymore).
Now, this algorithm fails precisely when there exists an i such that the largest increasing block starting from bi contains an element bj which is larger than at least one of the elements between bk and bi−1, where k denotes the position where bj gets placed after shifting the largest increasing block starting from bi to the left. If such a i doesn't exist, the largest block starting from 1 increases in length every time a number is shifted towards the left. Eventually, this block has length n. This is when we have the string 1,2,⋯,n. If such a i exists, we have a number whose position can't be changed anymore larger than a number to the right of it whose position can't be changed either, so we can't reach 1,2,⋯,n.
The existence of such an i is equivalent to the existence of some positive x,y,z satisfying bx+y<bx<bx+y+z. Let's call all permutations for which there exist such x,y,z good.
Claim: If a permutation is good, so is its inverse. Proof: Let {σ(i)}i=1n be a good permutation of {i}i=1n, and let {φ(i)}i=1n be the inverse of σ, so φ(σ(i))=i for all i. Now, there exist x,y,z such that σ(x+y)<σ(x)<σ(x+y+z). But, we also have that φ(σ(x+y+z))>φ(σ(x+y))>φ(σ(x)), so taking (x2,x2+y2,x2+y2+z2)=(σ(x+y),σ(x),σ(x+y+z)) does the job. ■
Using the lemma, it follows that if {i}i=1n can be reached from {bi}i=1n, {bi}i=1n can be reached from {i}i=1n. This shows that if A can be reached from B, B can be reached from A, completing the proof. ■
I'm well aware that my proof above is a very badly phrased one; sorry if some parts of it are very vague / hard to understand. I'll be glad to add clarifications to certain unclear parts in my solution if someone asks.
There also exists a nice solution using induction which my friend found. I can post it here if necessary. I'm looking for other's solutions here too!
That is very interesting
Let String = ab Now we can say that ab,ba (only two possible permutations using left arrows) both can be converted back to ab So we know this property holds true for n=2 Now take a string of length n, A1A2A3A4A5....An where Ai stand for a character i - integer Lets suppose the property holds true for string of length n Now lets prove it for string of length n+1 String S= A1A2A3A4A5....AnA(n+1) Now lets suppose We obtain string k. String k will of of the form 2. k = AiAj....ApA(n+1)........AqAr
If the string is in the first form we can consider AnA(n+1) to be a single character and this is similar to string n.
For second form Consider string X= AiAj....Ap.......AqAr (remove A(n+1) from string K) We can easily say that String X can be obtained from String Y = A1A2A3.....An as K is derived from S... (I can comment on this if any one finds the above statment difficult to understand)
From the assumption, we know String X can also be derived from Y.... Now we know (AiAj<-<-.....)Ap(..An...Ar) = A1A2A3...An The above ... denotes some set of Operations... So I want to denote them by O1 and O2
O1ApO2 = A1A2...An
Now for String K O1ApA(n+1)<-O2 will yield the result A1A2....AnA(n+1)
So we can prove that if this property holds for n then it also holds for n+1
Hence proved!!!!!
I am really bad at writing solutions..... I am not at all accustomed for this formatting and all......So please let me know if
Is each letter in the string considered distinct?
Log in to reply
Yes.