Five monkeys in a circus are sitting in the following order:
The ringmaster wants to reverse their order, but only by swapping the positions of two monkeys at a time.
This is one way, where two swaps take place:
1 2 |
|
Another possible way takes exactly four swaps:
1 2 3 4 |
|
Is it possible to do this in exactly three swaps?
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
great explanation!, just a detail, in the third and last drawings, you have the A, C and E curves intersecting at a single point, it should be 10 intersections in total, not 8
In your explanation, you have written : "let's consider the problem with 3 monkeys. Here is a chart of every possibility." I am unable to interpret this thing. If "problem with 3 monkeys, means swapping 3 monkeys", how does the chart depict it, can you please relate to it ?
Log in to reply
I replaced the wrong image fixing the other problem - I'll have to get to it on Monday.
Respected Sir and everyone , Please excuse me for posting this comment . Rather than saying that this is a comment this a burning issue in my heart . Please take it seriously .
Note : This post is regarding the Easy section of this problems of week .
I have a dream getting 100 or more up votes for an individual solution . I wrote a solution for the question water shadows (which is adjacent to this question) 6 days ago (on 21 April) . When I wrote the solution I thought it is a good one and will definitely accomplish my dream .
I am extremely happy when I saw that the question is in one of the problems of the week . I thought I am nearer to my dream because nobody posted any solution at that time expect me to this question and my solution is a clear and good one . But after these four days I am extremely sad because even more than 11,000 people solved that question only 83 people are discussing solutions . As a result at present I am only left now with 45 up votes . Although my solution deserves more than 100 up votes due silly reasons it is unable to accomplish my dream .
At first when I solved this question (infinite squares) on Monday morning I solved in the manner you did . I thought to post the solution but when I saw you have already posted the same solution (and now you got 299 up votes) . But I didn't worry at that time because I had hope that my solution to water shadows question will definitely cross 100 up votes .
Once see the up votes to the top solutions for the 5 questions of the problems of this week and see how odd it looks :
Infinite squares - Jason Dyer - 349 up votes
Water shadows - Ram Mohith - 57 up votes (see how odd it looks)
Third problem - Zain Majumder - 167 up votes
Fourth problem - Jeremy Galvagni - 129 up votes
Fifth problem - Micheal Mendrin - 250 upvotes
My point is that please try to discuss solutions to every question you solved and try to up vote the solution you admire as much as possible . If you do that many people like me will acheive what they deserve .
Please try to understand my problem .
Log in to reply
The science problems aren't as popular as the math, so they just won't get as many readers. That means there won't be as many people to upvote the solution.
Don't worry too much about it! (If you really need to compare, check against science problems in previous weeks)
Also, the very first problem will always have at least triple the audience (due to it occurring in email).
That was cool af, thanks for taking the time to write that out :)
The two examples provided show that the permutation (1,2,3,4,5) → (5,4,3,2,1) is pair .
The sign of a permutation σ ( denoted ϵ ( σ ) ) is defined as
ϵ ( σ ) = ( − 1 ) inv ( σ ) ,
where inv ( σ ) is the number of inversions of σ , or the number of pairs ( a , b ) with a , b ∈ { 1 , 2 , … , n } such that σ ( a ) > σ ( b ) , a < b .
Therefore the permutation cannot be computed using 3 inversions.
yeah....i guess i was a little overconfident
hey it is possible first do it E and D then do it with A and D then with E and B
Log in to reply
Nope, you end up with "EDCAB", not with "EDCBA"
Log in to reply
sorry my typing mistake it is A and D then B and E
Log in to reply
@Olevester Joram – D and E are the wrong way round.
This assumes the thing we are trying to prove, i. e. that three inversions cannot give the same configuration as two inversions
4 monkeys alone must be moved requiring if you imagine moving a monkey into the right place you can add 1. We need an addition of 5. In three moves this means that two of them must put two monkeys in the right place and one of them must only change one. There is no way to swap two monkeys such that one goes into the right place, without first swapping a pair of monkeys so that none are moved into the right place.
How can we rigorously show that the number of swaps must be even?
Log in to reply
After a swap operation, the number of inversions in the array modulo 2 will always toggle. This is provable using mod 2 parity and odd-even case analysis.
Log in to reply
More rigorous argument is https://en.wikipedia.org/wiki/Alternating_group using the even permutation argument.
Log in to reply
@Sidhant Bansal – Seems like you have read up on Group Theory in the last few months. Good job!
i support u on that
What about 3 monkeys? 2 must be moved but this can be done in an odd number of moves. One.
I think you mean the number of pairs to be swapped is even.
A and b, b and d, a and e.
hey it is possible first do it E and D then do it with A and D then with E and B
We can represent each permutation by its corresponding permutation matrix (having only zeroes except for exactly one 1 in each column and each row), for example the wanted monkeys permutation ( A , B , C , D , E ) ⟶ ( E , D , C , B , A ) is given by the matrix P that reorder the monkey's vector throw multiplication:
⎣ ⎢ ⎢ ⎢ ⎢ ⎡ 1 1 1 1 1 ⎦ ⎥ ⎥ ⎥ ⎥ ⎤ ⎣ ⎢ ⎢ ⎢ ⎢ ⎡ A B C D E ⎦ ⎥ ⎥ ⎥ ⎥ ⎤ = ⎣ ⎢ ⎢ ⎢ ⎢ ⎡ E D C B A ⎦ ⎥ ⎥ ⎥ ⎥ ⎤
In this language, the problem consists in rewriting the matrix P as a multiplication of transposition matrices (that only swap two letters), the first example given before is:
⎣ ⎢ ⎢ ⎢ ⎢ ⎡ 1 1 1 1 1 ⎦ ⎥ ⎥ ⎥ ⎥ ⎤ ⎣ ⎢ ⎢ ⎢ ⎢ ⎡ 1 1 1 1 1 ⎦ ⎥ ⎥ ⎥ ⎥ ⎤ ⎣ ⎢ ⎢ ⎢ ⎢ ⎡ A B C D E ⎦ ⎥ ⎥ ⎥ ⎥ ⎤ = ⎣ ⎢ ⎢ ⎢ ⎢ ⎡ 1 1 1 1 1 ⎦ ⎥ ⎥ ⎥ ⎥ ⎤ ⎣ ⎢ ⎢ ⎢ ⎢ ⎡ E B C D A ⎦ ⎥ ⎥ ⎥ ⎥ ⎤ = ⎣ ⎢ ⎢ ⎢ ⎢ ⎡ E D C B A ⎦ ⎥ ⎥ ⎥ ⎥ ⎤
Now suppose that this could be done with three transpositions P = T 1 T 2 T 3 then we would have
1 = det ( P ) = det ( T 1 T 2 T 3 ) = det ( T 1 ) det ( T 2 ) det ( T 3 ) = ( − 1 ) 3 = − 1
which clearly can't be true. Can you see why det ( T ) = − 1 for any transposition matrix?
This is my favourite answer. I didnt get any other answer. Thank you
For 3 swaps the number of monkeys must be a multiple of 3.
This is not true. Three swaps works if and only if the number of monkeys is 2, 3, 6, or 7. Note 2 and 7 are not multiples of 3, and no higher multiple of 3 works.
hey it is possible first do it E and D then do it with A and E then with D and B
Then for 2 swaps the number of monkeys must be a multiple of 2 which is not the case here. But 2 swaps situation is possible
Any permutation can be achieved by making a sequence of pairwise swaps. It is quite well known that the permutations of a given set fall into two classes:- those requiring an even number of swaps (and which cannot be done with an odd number of swaps), and those requiring an odd number of swaps (and which cannot be done with an even number of swaps).
Since the question shows us explicitly that the required permutation can be done with an even number of swaps we know immediately that it cannot be done with an odd number of swaps. In particular it cannot be done with three swaps
Here is a nice intuitive explanation of the parity property of permutations.
hey it is possible first do it E and D then do it with A and E then with D and B
Log in to reply
Hi Joram,
here is what happens with your three swaps...
ABCDE -> ABCED -> EBCAD -> EDCAB
You can see that you need one more swap (making an even number) to reverse the order completely.
The give order is :A,B,C,D,E The required order:E,D,C,B,A In both the cases C remains in the middle(2 positions far from the right and 2 potions far from the left). So in 3 swaps this arrangement is impossible because we need to first take C and swap with some other position and then swap it back again with the correct position hence twice the work ,therefore this work takes place for 2n times and three times swapping doesn't hold a stand.
Monkey C has to stay in the middle, so there are 4 left who "take" two of three swaps. Now the order is reversed and any third swap would break it.
No. One can prove in algebra, that for all n ∈ N + , that
π : S n ⟶ ( Z / 2 Z , + )
given by π ( σ ) = m o d ( L , 2 ) where L = length of a decomposition of σ into 2-swaps, is well-defined (and necessarily an homomorphism). Here we have an element (the permutation that reverses the order) in S 5 and we are counting up the length of a decomposition into 2-swaps: by the above, this is necessarily always even.
The fastest move is 2 steps. And if we want to let it slower, we only can add C move into it, but fastest move C to another position and back need 2 steps, 2+2=4, so we can't do it in 3 steps. (Maybe?)
I just thought, "The examples only show an even number of moves. There are an even number of monkeys that have to move, therefore, there can't be an odd number of moves to achieve the desired objective." Is this wrong?
Consider the following numeric function with 5 arguments:
f ( X 1 , X 2 , X 3 , X 4 , X 5 ) = ( X 1 − X 2 ) ( X 1 − X 3 ) ( X 1 − X 4 ) ( X 1 − X 5 ) ( X 2 − X 3 ) ( X 2 − X 4 ) ( X 2 − X 5 ) ( X 3 − X 4 ) ( X 3 − X 5 ) ( X 4 − X 5 )
Every two by two combination of the arguments are presented in the form of a unique difference, factor to the product. If all the arguments takes different numeric values, the result of the function will be different from zero, positive or negative. The signal of this value, changes when the values ( x and y ) of two arbitrary arguments ( X x and X y ) are swapped. This happens because:
A function defines an order over its arguments. I show here a function that changes its signal when we exchange an argument value for another, being numerical monkeys or otherwise. Another exchange and the signal returns to the original. An even number of exchanges leaves the function result invariant, an odd number flips its signal. Because a numerical result different from zero cannot be both positive and negative, a permutation achievable by an odd number of swaps cannot be reached by an even number, and vice-versa. This conclusion is not dependent on the number of monkeys.
Since we already verified that we can reverse the order of our monkeys by doing an even number of swaps, this excludes the possibility of doing it using an odd number of swaps, like three.
Given that the permutation can be performed using two swaps, the permutation is an element of the group A5. If we assume that the permutation can be performed using three swaps, then the permutation would not be an element of A5.
Problem Loading...
Note Loading...
Set Loading...
(This problem should be familiar with those who know group theory and know the terminology in Thomas's answer. However, the proof regarding odd/even parity of permutations can be a little technical. This is a non-technical presentation and includes the most intuitive proof of parity that I know of.)
First, let's consider the problem with 3 monkeys. Here is a chart of every possibility. If one sequence can reach another by a single swap, they are connected with a line.
By swapping, you can only flip between the bottom and top rows.
Move 1 (on bottom, move number is odd) -> Move 2 (on top, move number is even) -> Move 3 (on bottom, move number is odd) -> etc.
That means any sequence on the top row is reachable by an even number of moves and any sequence on the bottom or is reachable by an odd number of moves.
The same principle applies to this kind of operation (called a permutation) in general - if a sequence can be reached by an even number of moves, it can't be reached by an odd number of moves, and vice versa.
The general explanation is a little more involved, but below.
Write you starting sequence ABCDE, and then below write your first swap. Draw curves connecting each pair of letters, being careful so that any intersection only happens between two curves at one time. Keep going like this for each step, writing ABCDE on top and your new sequence on the bottom.
Note something very important: between each step, you can only add or subtract an odd number of intersections in one move . (See an example below where ABCDE gets changed to DBCAE.)
This is because between the two letters that get swapped exactly 1 intersection is added or removed, and then any curves in between the swap overlap at exactly 2 intersections, so any extra points added or subtracted must be done 2 at a time; this results in an odd intersection change number like 1 + 2 + 2 − 2 + 2 = 5 .
Since the sequence starts with an even number of intersections (0) each step of adding or subtracting an odd number of intersections swaps the number of intersections between odd and even.
(move 0) even number of intersections -> (move 1) odd number of intersections -> (move 2) even number of intersections -> (move 3) odd etc.
This means if we have a particular permutation where the final picture has an odd number of intersections, it will take an odd number of moves to get there. If we have a picture with an even number of intersections, it will take an even number of moves to get there.
In the case of our problem, we have a solution with an even number of intersections, so any solution at all will require an even number of moves.