A puzzled family
April 22nd, 2007 admin
This year started with several of my family members contributing several puzzles. I decided to compile them here since the puzzles were, firstly, interesting and secondly tell you a little bit about the people who asked them. Anant, my brother, sent the following in an email to me and my family. He said he found it on an IBM puzzler website. He, however, modified it a bit to make it more interesting to us all. Here’s Anant’s puzzle.
Anant’s Party Puzzle
Anil and Kavita attend a party with 3 other couples,including Srini and Shyamala (a couple). During the party everyone shakes hands with a certain number of other people that doesn’t include oneself and one’s spouse. At the end of the party Anil asks each person (apart from himself) how many people they shook hands with. He finds that each person answered truthfully and each one gave a different number. Anil did shake hands with Srini. From this information find out
1: Did Kavita shake hands with Srini?
2: Did Kavita shake hands with Shyamala?
Adapted from a puzzle found here (the last but one puzzle June 1998): http://www.research.ibm.com/ponder/
Solution:
Anil asks 7 people and gets 7 different handshake counts. The maximum count can be 6, since a person does not shake his own hand or his spouse’s. The 7 non-negative numbers (there cannot be negative counts) with a maximum of 6 are 0, 1, 2, 3, 4, 5, 6. Whoever has a count of 6 shakes hands with all the other people (other than his or her spouse, of course). Therefore, only that spouse can be the one with the 0 count. If Kavita were the person with the count of 6, no one but Anil could have had the count of 0. But Anil did hear someone else say 0. If Kavita were the person with a count of 0, no one else could have claimed 6. However, someone did. So Kavita does not have a count of 0 either. There is some couple with counts of 0 and 6. If that couple is removed from contention, everyone reduces in count by 1, the 1 coming from their handshake with the person with count 6. Anil and Kavita shook hands with one person in that couple (the one with the count 6). The remaining counts become 0, 1, 2, 3, 4. Whoever has the count of 4, partners the spouse with count of 0, using logic similar to above. Also, this couple cannot be Anil and Kavita. If Kavita had a count of 4, no one could have claimed a count of 0. If Kavita had a count of 0, no one could have claimed a 4. Therefore, the 4-0 pair is not Anil-Kavita. Again, Anil and Kavita shook hands with one person in that couple (the one with the count 4). Removing the 4-0 pair (originally the 5-1 pair) from contention, we have the counts of 0, 1, 2. 
Using similar logic as above, the 2-0 pair is not Anil-Kavita. Removing them (original pair 4-2), leaves Kavita alone with the count of 0. Bumping it back to the original count gives us 3. Kavita and Anil shook hands with one person in each couple, and, Anil and Kavita shook hands with the exact same people. So, to answer the specific questions - Yes, Kavita shook hands with Srini, and, No, Kavita did not shake hands with Shyamala.
Raghu’s Peanuts Puzzle
Later, when we visited my cousin and his family in New Jersey, he asked me and Anant a high protein mathematical puzzle laden with peanuts. I will recreate the puzzle from memory here.
There are 5 friends and a pet monkey. They also have a bag of peanuts. The are travelling through a tropical jungle in southern India when they decide to stop for the night in a clearing. They pitch the tent and go to sleep. One of the 5 friend wakes up in the middle of the night, a little hungry. He remembers the peanuts. He steps out quietly, careful not to wake anyone up, with the peanuts bag, divides up the peanuts into 5 even parts. He finds one extra peanut remains after the division. He feeds the remaining peanut to the monkey, eats his share and goes back to sleep. The other 4 friends wake up one after the other also and do the exact same thing as the first guy. Then, morning comes. Everyone wakes up refreshed and, unsurprisingly, a little hungry. They divide up the peanuts in the clearly smaller looking bag. And again just like each of them had found in the night, they find one peanut remaining. They feed that to the monkey, taking the monkey’s total intake to 6 peanuts, and eat the remaining peanuts. How many peanuts were in the bag when they pitched the tent?
Solution:
Raghu had asked me this puzzle about 4 years ago, when I had visited them in Alpharetta (near Atlanta), Georgia. I am not sure if my then recent exposure to discrete mathematics at Purdue University helped, or, as might be more likely, my mathematical intuition worked better then. I was actually able to solve the puzzle without resorting to a spreadsheet or a computer! This time around I found it harder to imagine up a way to solve it without a computer. I did find the answer with a spreadsheet program, but that was hardly consequential. More than getting the answer, this exercise was, for me, a journey in figuring out how to solve it without a computer. And in doing so I learnt something about what such problems are called and a generic way to solve them. This problem appears in several places in the web with coconuts in place of peanuts. The solution also appears in several places. I will try to recreate my approach.
Say, the initial number of peanuts is N.
When the first guy wakes up he sees N peanuts. When he is done eating there are (4/5)(N-1) peanuts.
When the second guy wakes up he sees (4/5)(N-1) peanuts, which is
(4/5)N - (4/5).
Similarly, when the third guy wakes up he sees, (4/5)[(4/5)N - (4/5) - 1] peanuts, which is
(4/5)2N - (4/5)2 - (4/5)
Extending the pattern, when the fourth guy wakes up he sees,
(4/5)3N - (4/5)3 - (4/5)2 - (4/5) peanuts
Extending the pattern, when the fifth guy wakes up he sees,
(4/5)4N - (4/5)4 - (4/5)3 - (4/5)2 - (4/5) peanuts
When they all wake up the next morning, they all see,
(4/5)5N - (4/5)5 - (4/5)4 - (4/5)3 - (4/5)2 - (4/5) peanuts
This, is again divided evenly amongst the 5, after a peanut is given to the monkey. That implies that the above count of peanuts is precisely 5k + 1, where k is some integer.
The final equation looks like,
(4/5)5N - (4/5)5 - (4/5)4 - (4/5)3 - (4/5)2 - (4/5) = 5k + 1
This reduces to,
(1024/3125)N-(1024/3125)-(256/625)-(64/125)-(16/25)-(4/5) = 5k+1
=> (1024/3125)N-(1024/3125)-(256/625)-(64/125)-(16/25)-(4/5)-1 = 5k
=> (1024/3125)(1/5)N-(1024/3125)(1/5)-(256/625)(1/5)-(64/125)(1/5)-(16/25)(1/5)-(4/5)(1/5)-1(1/5) = k
=> (1024/15625)N-(1024/15625)-(1280/15625)-(1600/15625)-(2000/15625)-(2500/15625)-(3125/15625) = k
=> (1024/15625)N-(11529/15625) = k
=> 1024N-11529 = 15625k
=> 1024N-15625k = 11529
Finally, we got the equation we were after. But wait a second, there are two variables(N and k) and only one equation! That is the equation of a line. You choose any value of N and you can always find a k. How are we to solve that for a single solution or a set of solutions?
Aha! Integers. N and k can take only integral values. So, even though this is the equation for a line, we are trying to find out if this line passes through the lattice points. Such equations have a special name - Diophantine equations. The one at hand, specifically, is a Diophantine equation of the first order, in two variables. These equations have been studied and solved in texts written between 800 BC and 500 BC in India. Aryabhatta and Brahmagupta (around 400AD to 650AD) gave general solutions to such equations and extended the study to higher order Diophantine equations and ones with more variables.
A generic Diophantine equation looks like ax + by = c, where x and y are the variables that must take integer values. a,b,c are integer constants. A equation of this type may have no solutions or infinitely many solutions. An example of an equation with no solutions is
2x + 2y = 5 (No Solution!)
The above equations has no solution because whatever the values of integral x and y, the left hand side is even and right hand side is odd.
A way to think of it is, you can draw a line on a graph paper such that it neatly avoids all the lattice points. I am not sure about this, but intuition tells me that if a line does cross through one lattice point, it will cross through infinitely many. That is, in other words, there are are either no solutions or infinitely many for a given Diophanine equation of the above form.
Now, coming back to the equation at hand, it is easy to see why a spreadsheet is a tempting approach. You vary N from 1 through a big number. You write k in terms of N, and visually inspect if K ever takes an integer value. Though this approach is what I tried at first, it is both ugly, unsatisfactory and unbounded. There might be no way to figure out if there exists no solution!
The solution that follows is based on the approach shown at this BBC webpage about Diophantine equations.
1024N-15625k = 11529
Now pay careful attention. The right hand side (11529) is odd. The first term on the left hand side (1024N) will always be even, whatever the value of N. The second term on the left hand side (15625k) will be even if k is even, and odd if k is odd. If k is even, the whole left hand side will be even. But since the right hand side is odd, this can’t be. Therefore k must be odd. We can, therefore write k is 2a+1. And the equation becomes,
1024N-15625(2a+1) = 11529
1024N-2(15625)a - 15625 = 11529
1024N-2(15625)a = 27154
Now notice that all the terms have a common factor of 2, which when cancelled out, leaves
512N-15625a = 13577, where k=2a+1
Continuing the above logic, and successively substitution 2b+1 for a, 2c+1 for b etc, when a or b should be odd and 2b for a, 2c for b etc. when a or b should be even, we get the following equations.
256N-15625b = 14601, where a=2b+1
128N-15625c = 15113, where b=2c+1
64N-15625d = 15369, where c=2d+1
32N-15625e = 15497, where d=2e+1
16N-15625f = 15561, where e=2f+1
8N-15625g = 15593, where f=2g+1
4N-15625h = 15609, where g=2h+1
2N-15625i = 15617, where h=2i+1
N-15625j = 15621, where i=2j+1
The final equation gives us,
N = 15621+15625j
The smallest positive solution therefore is N = 15621, when j = 0. This is one valid solution. Substituting N in the original Diophantine equation gives us k = 1023. So the 5 friends could have started with 15621 peanuts and had 1023 peanuts the next morning. Of course, they could have also started with 15625 + 15621 = 31246 peanuts (j=1 case) or even more.
I vaguely remember that this is how I had solved it in Alpharetta, GA, four years ago, without knowing anything about Diophantine equations and Brahmagupta or relying on spreadsheets.
My father’s Walkers Puzzle
Then, a few days back, my father, who loves his daily hour-long walks sent us this walking related puzzle. Later, when I wanted to confirm my answer, he informed me that he made the problem up but had not been able to solve it yet! The fact that he was able to think this up is by itself impressive considering the solution is not straightforward, yet, involves elegant abstraction. Since he thought this up when walking with his good friend who I call Subbanna Uncle, I will recreate the puzzle with my father, Kishore, and Subbanna Uncle participating in the activity.
ABCD is a rectangular park with a walking trail on all four sides. The rectangle is of dimensions a units by b units.
Two walking enthusiasts, Subbanna and Kishore, start walking around the park’s trail with same speed, S units per hour.
Subbanna starts at A and goes around the park covering all 4 sides each time repetedly, AD->DC->CB->BA->AD->DC… and so on.
Kishore starts at the same time as Subbanna but starts at B and walks around the park covering 3 sides repeatedly, BC->CD->DA then he turns back to trace AD->DC->CB, turns back again and so on.
1: How many times do Subbanna and Kishore cross each other while walking for a time period of t hours?
2: How many times do Subbanna and Kishore walk side by side in the same direction?
3: What is the time period before the two walking routines repeat an earlier pattern?
Solution:
The park is a rectangle with sides measuring a units and b units as shown.

The pattern that Subbanna follows is shown with a yellow/orange line and the pattern that Kishore follows is shown with a green line.

The beauty of this problem is that it is easier to solve the puzzle by opening up the paths. Both the paths taken by the two walkers are repetitive. What we need is a repetitive representation that would show intersections of the paths accurately, while clearly laying out the paths in time, so that a repetition does not overlap a previous representation. I chose to keep time on the x-axis and label the corners A,B,C,D on the y axis. The speed being constant keeps the path traced by the walkers straight lines on this graph, and also helps assign a scale for the x-axis. 
Subbanna’s pattern repeats every (2b+2a)/S hours, while Kishore’s repeats every 2(2b+a)/S hours, as is clear from the graph. While Kishore is going in the BC->CD->DA direction (downward) he intersects Subbanna’s path once or twice. He cannot avoid intersecting because the distance between two parallel orange lines is less than the length of Kishore’s downward path. If Subbanna’s orange line intersects Kishore’s upward path (AD->DC->CB), that has to be the time they walk together.

After time t, the projection of time on to an axis parallel to Kishore’s downward path, is t*S distance units. This is shown as T is the figure, however, to avoid confusion let us continue to use S*t for that distance. In this time, every orange line (Subbanna’s one loop) causes an intersection with Kishore, except if they overlap. Put mathematically,
the total number of intersections = total number of orange lines - number of times orange line and upward green line coincide
total number of orange lines = (t*S - (2b+a)/2)/(b+a) + 1
“number of times orange line and upward green line coincide” is a little more involved. The first time they coincide, (2b+a)/2+n*(b+a)=m*(2b+a), where m and n are integers. This implies,
n*(b+a)=(m-1/2)*(2b+a)
Multiplying by 2 on either side,
2n*(b+a)=(2m-1)*(2b+a)
If (b+a) and (2b+a) are integers,this will happen if 2b+a is even. If 2b+a is odd, this will never happen and Kishore and Subbanna’s paths never coincide. If (a+b) and (2b+a) are not integers, then I am not sure what the condition is for the paths to not coincide. I assume they will always coincide.
From them on they coincide when k*(b+a)=l*(2b+a), which is every LCM(b+a, 2b+a) units.
Therefore, “number of times orange line and upward green line coincide” = (0 or 1)+(S*t)/(LCM(b+a,2b+a))
Here are the final answers:
1: How many times do Subbanna and Kishore cross each other while walking for a time period of t hours?
(t*S - (2b+a)/2)/(b+a) + 1 - (0 or 1) + (S*t)/(LCM(b+a,2b+a))
2: How many times do Subbanna and Kishore walk side by side in the same direction?
(0 or 1)+(S*t)/(LCM(b+a,2b+a))
3: What is the time period before the two walking routines repeat an earlier pattern?
The time period is when the original situation repeats. That is Kishore is at B and Subbanna is at A.
LCM(2*(2b+a)/S, (2b+2a)/S)
Note: I have used LCM for Least Common Multiple, and I do not restrict it to integers alone.
Posted in Tidbits | No Comments »