Problem
You are sitting in front of two drawers. The left drawer contains 64 pennies, the right drawer contains nothing. Can you arrange things so that one of the drawers has 48 pennies, using the following two operations:
- L
- If the left pile has an even number of pennies, transfer half of them to the right pile. If the left pile has an odd number of pennies, operation L is disallowed.
- R
- If the right pile has an even number of pannies, transfer half of them to the left pile. If the right pile has an odd number of pennies, operation R is disallowed. ------------------------------------------------------------------------------------------------------------
Answer
- Limitations:
- The only operation one can do is to remove half of the coins from one drawer and move it into the other drawer.
- At the start I was too focused on trying to find a way from working top to bottom, when I completely brushed off the idea that I could have went from bottom top. Instead of trying every possible way of getting the drawer to size 48, we can try to start from 48 coins and make some drawer with all 64 coins.
- So lets think about this logically. If we have one drawer with 48 coins, the other drawer MUST have 16 coins. We`ll call the drawer that has 48 coins 'Drawer A' and the drawer with 16 coins 'Drawer B'. Now we have to reverse engineer the rules given in the problem. We are only allowed to remove half of the coins from a drawer at a time. This would mean that, if I removed half the coins in drawer Y (an arbitrary drawer), drawer Z would have Y's current number of coins plus the coins that already existed in its own drawer (if it had any). This basically means that the number of coins in Y after the swapping, can NEVER be more than the number of coins in Z.
- Now lets look at our current situation. We have Drawer A with 48 coins and Drawer B with 16 coins. We just concluded that, after the swap, drawer y can never be more than the coins in drawer z. This means that the last transition in our problem could have never been from A--> B, meaning, the last transition was cutting Drawer B's coins in half.
So to 'undo' this move, we must double B's number of coins, and subtract A's coins by the amount of coins we increased B by. So our current situation is: Drawer A: 32 Drawer B: 32. At this point we can see that both drawers have the same number of coins. This only means one thing; one drawer had all of the coins at a point, and it has been split by half and separated between the two drawers. Thus we can state that one drawer had 64 coins in total.
So is there a way to find a set of numbers in which this technique work? What are the different number of starting number of pennies can we have that could lead us to having a drawer with 48 coins while only using these 2 rules? Is there a relationship between the values?
Lets try experimenting.
* it is important to note that the drawer which had the lower amount of coins must be the one that keeps gaining coins. If there is a point where that drawer exceeds the amount of coins in the other drawer, it is impossible to get one drawer with all the coins. The reason for this is because if you increase drawer B, and it exceeds the other drawer, you'll be rotating back and forth between two numbers.
Example:
Drawer A has 48 coins. Drawer B has 12 coins.
Drawer A has 36 coins Drawer B has 24 coins
Drawer A has 12 coins Drawer B has 48 coins
Drawer A has 24 coins Drawer B has 36 coins
The beauty of trying it bottom top is that there is only one possible way you can move. You don't have to debate on whether you should do it one way or another. So it is guaranteed that this won't work.
Then there are two cases. The drawer with 48 coins is the smallest, or the other drawer is the smallest.
Case 1: #Drawer with 48 coins is the bigger drawer
That means, the pattern should follow this structure. At at any point, if one of the drawers were to be 0, then we have a winner.
Drawer A has 48 coins. Drawer B has x coins.
Drawer A has 48-3x coins Drawer B has 4x coins
Drawer A has 48-7x coins Drawer B has 8x coins
Drawer A has 48-15x coins Drawer B has 16x coins
.
.
.
.
.
Drawer A has 48 - [ (2^t) - 1 ]*x Drawer B has 2^t * x coins where t is the turn number
.
.
rewritten:
Drawer A has 48 - x(2^t) - x Drawer B has x(2^t) coins where t is the turn number
So if Drawer A is the drawer with the most coins at the start, if there exists a t such that 48 - x(2^t) - x = 0, where x is the number of coins in the other drawer at the start, it is possible for 48 + x coins to be in one drawer at turn t. If not, it is impossible.
- Case 1: #Drawer with 48 coins is the smallerdrawer
That means, the pattern should follow this structure. At at any point, if one of the drawers were to be 0, then we have a winner.
Drawer A has 48 coins. Drawer B has x coins.
Drawer A has 96 coins Drawer B has x - 48 coins
Drawer A has 192 coins Drawer B has x - 48 - 96 coins
Drawer A has 384 coins Drawer B has x - 48 - 96 - 192 coins
.
.
.
.
.
Drawer A has (2^t)*48 Drawer B has x - 48(2^t - 1) coins where t is the turn number
So if Drawer A is the drawer with the lestcoins at the start, if there exists a t such that x - 48(2^t - 1) = 0 where x is the number of coins in the other drawer at the start, it is possible for 48 + x coins to be in one drawer at turn t. If not, it is impossible.
Either or, the three cases to this problem is number of coins in drawer a > drawer b, drawer a < drawer b, or drawer a = drawer b, which we can instantly conclude that it can be brought into one drawer.