Francois Flip Frenzy

Francois arranged 40 coins in a line from left to right on the table with each coin showing heads. Francois repeatedly chooses two coins, such that the leftmost coin (of the two) shows heads and flips over both the coins. What is the most number of times Francois can flip a pair of coins before he is unable to flip any more coins?


The answer is 780.

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.

8 solutions

Matt McNabb
Sep 16, 2013

Let's imagine we have 40 spaces and each space could contain a head. Instead of tails I'll use blank space , this makes the language a bit simpler.

The effect of one of Francois's flip is either: (a) Remove two heads, or (b) Move a head to the right.

If a maximal sequence contains a move of type (a), then it must be removing two heads from the two right-hand spaces. Because if it were removing any other two heads, we could replace that by the longer sequence of moving the heads to the right and then removing them.

If a maximal sequence contains a move of type (b) then it must be moving a head one space to the right. Otherwise we could replace that move by a series of moves of a head one space to the right.

So the longest possible sequence is, starting from n = 0 n=0

Step n n part 1: Move the right-most two heads to the far right

Step n n part 2: Remove two heads from the right

and we repeat this until all heads are gone.

Now, part 1 requires 4 n 4n moves: we're moving two coins and each coin has to go as many spaces over as coins we've removed so far.

Part 2 is just 1 1 move of course.

And we make 20 20 steps in total because each step removes 2 2 coins and there are 2 × 20 2\times20 coins to remove.

So the value we want is 20 × 1 + 4 ( 0 + 1 + 2 + . . . + 19 ) = 20 + 4 × 190 = 780 20\times1 + 4(0 + 1 + 2 + ... + 19) = 20 + 4 \times 190 = \boxed{780}

We can label the coins with the numbers 0,1,2,3,4,...,n-1 from the right to the left. If a coin shows head its value is 0, else if a coin shows cross its value is equal to its label. The sum of all coin's values increases in each flips (in fact in each step there is a coin on the left that shows head). The starting value of this sum is 0. The maximum value is 0+1+2+...+n-1 = n(n-1)/2. So we can do maximum n(n-1)/2 flips. The algorythm to obtain exactly n(n-1)/2 flips is just shown.

Thomas Disy - 7 years, 8 months ago

Log in to reply

Awesome, that explains the "shortcut solution" someone else posted too.

Matt McNabb - 7 years, 8 months ago

Beautiful solution thanks

Pranav Rao - 5 years, 5 months ago

i did like this too, but it's too hard to write down though.

Cuong Doan - 7 years, 8 months ago

Brilliantly done. Most people would have seen the pattern but writing a proof would have been very hard.

I tried recursion. It gives the answer by pattern recognition but proof seems to be hard to come by.

Mirza Baig - 7 years, 8 months ago

Log in to reply

Well this is how I saw it:

For n = 2, you go HH to TT, one step, simple. For n = 3, you add another H to the right. So now you have HTT. Then you essentially move that H to the right most space, adding two more steps. For n = 4, you add yet another H, doing the same thing (this time, adding 3 more flips since there are 3 more spaces). From a conceptual standpoint, this is WHY that when you have n coins, the answer is the n-1th triangle number.

Michael Tong - 7 years, 8 months ago

Actually using your method we can come up with a recursion proof as well.

Mirza Baig - 7 years, 8 months ago

Log in to reply

Yeah - you can remove the rightmost two coins and then move all other coins right twice , then you forget about the left-most two spaces and start again. It's fairly similar.

Matt McNabb - 7 years, 8 months ago

An extension to this problem could be: how many ways are their to do n ( n 1 ) / 2 n(n-1)/2 flips?

Python could deal with that handily for our n = 40 n=40 case, but I'm wondering if there's a closed-form expression. (I suspect there isn't, based on thinking about it for a little while, but I figured I'd throw it out to anyone who might like to try.)

Peter Byers - 4 years, 10 months ago
Piotr Kaminski
Sep 16, 2013

Here's an informal solution based on pattern-matching. We'll simulate the optimal (longest) sequence of coin flips for 2, 3, 4 and 5 coins based on the principle that we always want to pick the rightmost heads and the leftmost tails, since once there are no heads to the left of a tails it's "stuck".

H H
T T  ->  2 coins, 1 flip

H H H
H T T
T H T
T T H  ->  3 coins, 3 flips

H H H H
H H T T
H T H T
H T T H
T H T H
T T H H
T T T T  ->  4 coins, 6 flips

H H H H H
H H H T T
H H T H T
H H T T H
H T H T H
H T T H H
H T T T T
T H T T T
T T H T T
T T T H T
T T T T H  ->  5 coins, 10 flips

The pattern seems clear: f ( n ) = n ( n 1 ) 2 f(n) = \frac{n(n-1)}{2} , and f ( 40 ) = 780 f(40) = 780 . Not a proof of course but sometimes a good guess is good enough.

Why is a guess voted second top? That's kind of disappointing to me...

You could have at least mentioned (or noticed?) that when you go n = k to n = k + 1, you essentially just add an H to the left, and then move that H all the way to the right. For example

HH

TT

then

HTT

THT

TTH

then

HTTH

THTH

TTHH

TTTT

etc.

Michael Tong - 7 years, 8 months ago

Great. I have the same solution

Yow Ka Shing - 7 years, 8 months ago
James Aaronson
Sep 15, 2013

We prove that the answer is 1 + 2 + . . . + 39 = 780 1 + 2 + ... + 39 = \boxed{780} .

Clearly we can manage this, by flipping the rightmost pair, then the rightmost two pairs from left to right, then the rightmost three pairs from left to right, and so on (so flip pairs 39, 38, 39, 37, 38, 39, ...).

Conversely, we prove that the pair whose left coin is coin n n can be flipped at most n times (giving rise to an upper bound of the sum above). We prove this inductively - clearly pair 1 can be flipped only once, and pair n 1 n-1 must be flipped between each flip of pair n n , so there can be at most one more flip of pair n n , as required.

Krishna Meena
Sep 15, 2013

It uses simple Combination. We have 40 coins and choose 2 coins. So, ( 40 2 ) = 40 ! 2 ! ( 40 2 ) ! \left(\! \begin{array}{c} 40 \\ 2 \end{array} \!\right) = \frac{40!}{2!(40-2)!} = 780

I suggest you reread the problem. Unfortunately, this gives the correct answer.

Daniel Chiu - 7 years, 9 months ago

Log in to reply

It'd be interesting to find a way of looking at the problem so that this answer makes sense.

Matt McNabb - 7 years, 8 months ago

Log in to reply

Yes. I don't see how that could be done, but it is interesting.

Daniel Chiu - 7 years, 8 months ago

Log in to reply

@Daniel Chiu Unluckily, that is expected. The correct answer for n n coins is n ( n 1 ) 2 \frac{n(n-1)}{2} , which is also equal to ( n 2 ) {n \choose 2} .

Sreejato Bhattacharya - 7 years, 8 months ago

@Daniel Chiu Tomas D. explained it elsewhere on the thread.

Number all the squares 0 , 1 , 2 , . . . , 39 0,1,2,...,39 from right to left. Consider the sum of all numbers that have tails on them. It starts off at 0 0 , and each possible move increases is sum. (In my solution the moves I use increase the sum by exactly 1 1 ). When all the heads are gone the sum is 0 + 1 + 2 + . . . + 39 = 40 C 2 0 + 1 + 2 + ... + 39 = {}^{40}C_2 , so this is the maximum number of possible moves.

Matt McNabb - 7 years, 8 months ago

I'm a bit surprised that a totally wrong statement still leads to the read answer

Cuong Doan - 7 years, 8 months ago

Its just an illogical solution having the same answer by coincidence (due to the imposed conditions).

Arnab Animesh Das - 7 years, 8 months ago

Log in to reply

The coincidence actually holds for all positive integers!

Sreejato Bhattacharya - 7 years, 8 months ago

Log in to reply

If somebody would kindly prove it in these comments, or even better, in the discussions. It would be great. If it holds true, then it's surely an interesting topic.

Arnab Animesh Das - 7 years, 8 months ago

Log in to reply

@Arnab Animesh Das It does hold true. The fact that for n n coins the result is n ( n 1 ) 2 \frac{n(n-1)}{2} has been proved in James A.'s solution. But again, note that n ( n 1 ) 2 = ( n 2 ) \frac{n(n-1)}{2}= {n \choose 2}

Sreejato Bhattacharya - 7 years, 8 months ago

Simple Combination, That`s great!

Sanjay Meena - 7 years, 8 months ago

Log in to reply

Great, but wrong!

Sreejato Bhattacharya - 7 years, 8 months ago
Sumit Goel
Sep 15, 2013

Assuming we can flip a maximum of N times for A coins. So after flipping N times the sequence would be TTTTTTTTT (A-1 times) with H or T in end.

For A+1 coins after flipping pair of coins N times we get to a situation like H TTTTTTT (H/T). We can make another A flips in this sequence by flipping the coins (1,2),(2,3),(3,4)...(A,A+1) in order. so if we can flip N times for A coins we can flip N+A times for A+1 coins.

A=2 N=1

A=3 N=3

A=4 N=6 so

A=40 N=39*40/2=780

Let a n a_n be the maximum number of flips possible with n n coins. Note that a 2 = 1 a_2=1 , because when there are 2 2 coins, a single operation exhausts all the coins showing heads. Now we shall determine a relationship between a n + 1 a_{n+1} and a n a_n .

Label the n + 1 n+1 coins 1 1 , 2 2 , \cdots , n + 1 n+1 from left to right. We first ignore coin 1 1 , and consider the set { 2 , 3 , . . . , n + 1 } \{2, 3, ..., n+1 \} . We can flip these coins in at most a n a_n ways. Note that after these coins are flipped, coin 1 1 will show head, and all coins from the set { 2 , 3 , . . . , n } \{2, 3, ..., n\} will show tails. The ( n + 1 ) t h (n+1)^{th} coin will either show head or tails (depending on the parity of n n ). After we have applied the operation a n a_n times on the set { 2 , 3 , . . . , n + 1 } \{2, 3, ..., n+1\} , we take the set { 1 , 2 } \{1, 2\} and flip them. Then coin 2 2 will show heads, and we do the same for 3 3 . We then keep on doing this until we reach the set ( n , n + 1 ) (n, n+1) . Note that this is the optimal strategy here, since this keeps the left-most coin showing heads for the longest number of operations. Hence we obtain the recurrence relation a n + 1 = a n + n a_{n+1}= a_n + n . We can easily solve this recurrence relation using the fact that a 2 = 1 a_2= 1 : a n = 1 + 2 + . . . + ( n 1 ) = n ( n 1 ) 2 a_n= 1+2+...+(n-1)= \frac{n(n-1)}{2} At n = 40 n=40 , it equals to 39 40 2 = 780 \frac{39*40}{2} = 780 .

Peter Byers
Jul 27, 2016

Assign each coin a value equal to its distance from the rightmost coin. (Thus, for 40 coins, the values assigned will be 39,...,0.) The problem specifies that the setup is all-coins-showing-heads, but we can prove by induction that for any setup the maximum number of flips that can be performed is equal to the sum of the values of all coins that show heads, which we designate V V .

First note that it is irrelevant whether the rightmost coin shows heads or tails (i.e. it doesn't affect the value of V V and it will never affect whether a particular flip is legal or not), so WOLOG we can assume it shows tails. (Alternately put, we can replace it with a two-tailed coin.)

Now V = 0 V=0 if and only if all coins show tails, in which case no flips are possible. For the inductive step, V > 0 V>0 means that one or more coins (not the rightmost one) show heads. Francois can choose the rightmost out of those coins, together with the coin (showing tails) to its immediate right. Then the new sum of head-values is V 1 V -1 as desired, which completes the proof (since any other flip he could choose would also decrease the sum by at least 1 1 ).

Let c ( n ) c(n) be the number of turns of n coins when only the left most coin is heads and all the other coins are tails with the right most coin being optionally heads or tails (does not matter). Then c ( 1 ) = 0 , c ( 2 ) = 1 c(1)=0, c(2)=1 . c ( n ) = 1 + c ( n 1 ) c(n)=1+c(n-1) . This is because in the c(n) configuration, only the left most coin is heads and all the others are tails and in choosing the two coins, the most number of turns is obtained when we choose the left most coin (forced) and the coin immediately right of it. Any other choice of the second coin will result in lesser number of overall turns. But in the c ( n ) c(n) configuration, when we flip the coin immediately right of the left most coin, the configuration of the second to last from the left coins is exactly the c ( n 1 ) c(n-1) configuration.

Let t ( n ) t(n) be the total number of turns when we start with all heads. Then t ( n ) = c ( n ) + c ( n 1 ) . . + c ( 1 ) t(n)=c(n) + c(n-1) .. + c(1) . Applying c ( n ) = 1 + c ( n 1 ) c(n)=1+c(n-1) recursively, we get, t ( n ) = ( n 1 ) + ( n 2 ) + . . + 1 t(n) = (n-1) + (n-2) + .. + 1 . So t ( n ) = ( n 1 ) n 2 t(n) = {(n-1)n \over 2} . For n = 40 n=40 , we have t ( n ) = 780 t(n) = 780 .

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...