Main title - Anil Krishna's WebPage

Tidbits

This page will primarily contain Mathematical, Scientific, Computing or even everyday facts that I find useful ... at work or play.

A puzzled family

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/

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?

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?
Solutions
Posted By: Anil Krishna at 09:00PM on Sunday, April 1st, 2007

I don't know. I don't know. Now I know. Now I know!

My friend Srikanth, aka Coffee, sent this question to the egroups after hearing the one Anant had asked me.
A reporter meets two famous mathematicians P1 and P2 in a train and tells them that he is going to whisper the sum of two 2-digit numbers into P1's ear and their product into P2's, and then he wants them to guess what those two 2-digit numbers were. After he has whispered the sum and the product to P1 and P2 respectively, the conversation goes as follows:
P1: I don't know.
P2: I don't know either.
P1: Now I know.
P2: Now I know too.
What are the two numbers? Read More
Posted By: Anil Krishna at 12:30 PM on Sunday, September 3rd, 2006

I don't know. I know that. Now I know. I know too!

Anant asked me this question. He had heard it in a talk by an executive at Cisco Systems.
There are 2 numbers X and Y (integers).
2 <= X < Y <= 100
Person 1, P1, knows X * Y (product).
Person 2, P2, knows X + Y (sum).
P1 knows that P2 knows the sum, P2 knows that P1 knows the product.
They have this conversation:
P1: I do not know what X and Y are.
P2: I knew you would not know.
P1: Now I know what X and Y are.
P2: Now I too know what X and Y are.
What are X and Y? Read More
Posted By: Anil Krishna at 9:45 PM on Thursday, August 24th, 2006

A diagonal through a rectangular grid of squares

Anant asked me this question. He had heard it in a talk by an executive at Cisco Systems.

"There is a rectangular grid composed of 1x1 squares (i.e unit squares). The grid measures m squares by n squares. How many squares will a diagonal pass through?"

There are potentially many ways to compute a solution to this one. A deep dive into discrete mathematics is one way to tackle the problem, but the fact that an executive asked the question made be believe that there had to be a more elegant approach to solving it. The lesson the executive wanted to share with his colleagues was, probably, that a problem may have only one solution, but there may be a more elegant way to get to it and a less elegant way. Elegance of a solution is probably as important an aspect as correctness. Elegance not only saves time, but it also makes the solution easy to implement, understand and sell. I believe elegance should be a criterion to further qualify a solution beyond it's correctness. Read More
Posted By: Anil Krishna at 2:30 PM on Sunday, August 20th, 2006

Poisoned Wine

You are the Monarch of an Island and are about to have a festival tomorrow. The festival is the most important one you have ever had. You've got 1000 bottles of wine you were planning to open for the fiesta, but you find out that one of them is poisoned by some evil scoundrel. The actual poison exhibits no symptoms until somewhere around the 23rd hour, then results in sudden death. You have thousands of prisoners at your disposal.

1. What is the smallest number of prisoners you must have to drink from the bottles to find the poisoned bottle?
2. What is the smallest number of prisoners that you must sacrifice?
3. For the strong minded, what is the smallest number of prisoners if more than one bottle (say 2) is poisoned? Read More
Posted By: Anil Krishna at 8:11 PM on Sunday, June 4th, 2006

Send More Money

My father asked me this question over the phone this weekend.

"A college going kid's father, tired of his sons repeated requests for money throws him a challenge. He asks the son to solve a math puzzle, before expecting any more money from the dad. SEND + MORE = MONEY is a mathematical equality, where each letter is a unique numeral. What is the equality in numbers?". Read More
Posted By: Anil Krishna at 9:45 PM on Wednesday, October 19th, 2005

Binary vs ASCII Files

The difference in how a file is written into memory is crucial in knowing how to read it. If a file is written using fprintf, then the data in the file is stored as a sequnce of ASCII characters. This creates a file in the ASCII format. If the was written using fwrite, then the data would be stored as one of many data types depending on what the fwrite is writing. Read More
Posted By: Anil Krishna at 2:10 AM on Sunday, July 17, 2005

Probably irrelevant

There are a 100 people trying to get onto the same flight you are. The airplane has a 100 seats. You are all ready to board. You are the last one in the line of passengers at the gate. The first guy walks in to the flight and promptly realizes that he does not have his boarding pass on him and does not remember his seat number. So he picks one at random, hoping his charm will take care of the after effects. Every one else takes their assigned seat if it is available. If someone is already sitting on it they quietly look for an empty one and sit there. By the time you get in there is only 1 seat left. What is the probability that the seat which remains is indeed the one originally assigned to you?
This problem, I heard on National Public Radio's show called Car Talk a couple of weekends back, and immediately set to solving it. I solved it in about 15 minutes with relatively straight forward mathematics, but had the nagging feeling that the problem did not deserve the insight-less fiddling around with drone mathematics, and instead had a much more elegant and insightful, logical solution. I had to wait for the next show for the answer, which as I suspected was crisp and short.
Read More
Posted By: Anil Krishna at 8:42 PM on Sunday, Oct 17, 2004

2's Complement and the trick to negate it!

"2's complement" is an often heard phrase in the world of computers. It is a notation used to represent numbers to ease subtraction. The intuitive binary number notation only stays positive, adding higher powers of 2 to the number as you keep adding 1's to the left of a number. The most intuitive way to denote a negative of a number is to place a "-" symbol to its left. So if in decimal -5 is negative of 5, why can we not live with -101 for negative 101 (101 is binary for decimal 5) in binary? We can, but this "-" symbol is an abstraction useful to think about the number. A computer, which can only identify a 1 or a 0 (a high or a low voltage), needs to represent the "-" symbol  using a trick. Read More

Posted By: Anil Krishna at 8:30 PM on Friday, October 15, 2004

Forget forgetting

Here is a miraculous solution to the age old problem of forgetting birthdays and anniversaries. A perl script that can send you email every morning about what's coming up for the next week, so not only do you remember, but you have enough time to set up something special ... like a surprise birthday cake!
OK enough of the introduction. Essentially it is a simple perl script that I run on my Unix machine. At it has already proven its worth. So this is for those of you who are looking for a similar tool.
Read More
Posted By: Anil Krishna at 5:51 PM on Saturday, Jul 17, 2004

Swapping or a circular shift without temporary storage

Normally when you want to swap (exchange the values of) two variables, the most intuitive way is to store the value of one in a temporary variable. Overwriting the safely-stored variable's value with the other one. And then overwriting the other variables value with the stored variables value. At this point since the swap is done the temporary variable may be deleted.
An interesting, thought provoking and equally symmetric way of doing the same action, without the use of a temporary storage is by using the bitwise XOR operation. Read More
Posted By: Anil Krishna at 00:18 AM on Monday, May 10, 2004

Big-Endian and Little-Endian Storage Schemes - How to remember ...

Computer systems today primarily store "words" of data in either Little or Big Endian format, in the physical memory. By "word" I mean a piece of data that is larger than a byte. Typically a word is defined as 2 or 4 bytes, and halfwords, double words, quadwords are extrapolations thereof. Intel machines store data in their memory, in Little Endian format and IBM PowerPC architecture stores data in Big Endian format. The differences are critical when writing a compiler or when transferring a piece of data written for one system to another. Read More
Posted By: Anil Krishna at 7:10 PM on Saturday, May 8, 2004

Some simple summations

Old problems are sometime good to sit and ponder because you know that the solution is not beyond you, but at the same time you can challenge yourself to get back into the frame of mind of thinking about these issues. One such problem is the summation
1 + n + n(n-1)/2 + n(n-1)(n-2)/2.3 + ... + n + 1
Do you know of a way to reduce this? How about using plain algebra? Read More
Posted By: Anil Krishna at 11:00 PM on Tuesday, April 27, 2004

A million days from now

I am reading a book called In Code - A young woman's mathematical journey written by Sarah Flannery. In one of the chapters while trying to explain the concept of modulo arithmetic, she poses an interesting question along the lines of,
"Say today is Saturday, what day of the week will the millionth day from today be?" Read More
Posted By: Anil Krishna at 8:40 PM on Saturday, Feb 21, 2004

Copyright © 2003-2006 Anil Krishna