display | more...
There are two friends, S and P.
And there are two integer numbers, K and L : 1 < K, L < 100
"S" knows only the sum of those two numbers and "P" knows only the product.

Here is their little discussion...

P: I do not know the numbers...
S: I knew that you didn't know them. I do not know them either.
P: But now I know them!
S: Now, I know them too!

Which are the two numbers K, L ?
Incredible though it may seem, this is no joke. It has an absolutely straight answer (like, say, the numbers K, L are 17 and 51), and a proof which, either can contain maths, either just be brute-force.


We, as good computer-geeks, will approach the quiz with brute-force :-)
But, really, before you take a look at the solution you should give it a try!

Anyway, here we go.

P says: I do not know the numbers.

So, we can be sure that the product that P knows, can be analysed in more than one way. We name such a product a "fuzzy product".
Here is an example ( P = 50 = 5 * 10 = 2 * 25). P can't really know whether 5, 10 or 2, 25 are the numbers K, L. But if P was 55, then the numbers K, L would definately be 5, 11.

S says: I knew that you didn't know them. I do not know them either.
From the first part of S's answer, we understand that S has such a sum that every possible K, L pair corresponding to this sum gives a fuzzy product.
And here I shall invoke The Computer!
Don't be frightened! I wrote this small (20 lines pure C) program to do da dirty job!

#include <stdio.h>

int fuzzy(int x){ // Determines if x is a fuzzy product
  int i,j,s=0;
  for(i=2;i < 100;i++)
    for(j=2;j < 100;j++)
      if (x == i*j) s++;
  return s > 2; // because we must consider that pairs 5, 11 and 11, 5 are                                              
}               // considered the same pair


int main(){
  int sum,x,tmp;
  printf("Good Sums : ");
  for(sum=4;sum <= 198;sum++){ // since K, L are between 2 and 99 ...
    x=2;

    while ((tmp=fuzzy(x*(sum -x))) && (x = x+1) && (x+1 < sum));
    if (tmp) printf("%d, ",sum);
  }
  printf("\n");
  return 0;
}
==> Program Ends Here <==

And the long-awaited output is...

Good Sums : 11, 17, 23, 27, 29, 35, 37, 41, 47, 53
(So, OK, I cheated, I ate up the last comma manually!)

So, let's name those sums that have only fuzzy product solutions, good sums.
One example to make that more clear: If you take any of the above sums, and check all possible combinations which yield that sum, you will find out that all of them have a fuzzy product.
11 = 2+9 = 3+8 = 4+7 = 5+6
  • 2*9 = 18 = 3*6 (so, 18 is fuzzy)
  • 3*8 = 24 = 4*6 (so, 24 is fuzzy)
  • 4*7 = 28 = 2*14 (so, 28 is fuzzy), and...
  • 5*6 = 30 = 2*15 (so, 30 is fuzzy), thus, all combinations for 11 give fuzzy products.
So, it is now obvious that S has one of the above 10 sums, or else he wouldn't be sure that P has a fuzzy number, and thus wouldn't have said that "I knew that you did not know them".

P says: But now I know them!

FGS! (For God's Sake) How did P found those numbers?!
Well, when P heard S saying that he (S) knew that he (P) didn't know the numbers in the first place, he made the calculations above and found out that S had one of those 10 sums(which produce only fuzzy products).
But thou shall not forget that P, being P, knows P :-) (the product)
So, P knows P and those 10 possible sums. Hence, the only thing he can do now is to solve those 10 equation systems with 2 unknowns and 2 equations and hope that only one of those equation systems has a valid solution.

{ K + L = S
{ K * L = P
with S = {11, 17, 23, 27, 29, 35, 37, 41, 47, 53}
and P known (to our friend P)

But we know from P's answer that he found the numbers, and that means one thing: only one of those equation systems has a valid solution.

S says: Now, I know them too!
Of course, S does not have the privilege to know the product P. The only thing that he knows (except from S :-) are the ten equation systems from which P found the numbers.

CAUTION
: For the skeptics: if you intend to ask, how he (S) knew the ten equation systems, just think that if we, the readers, could think of them, S could also do it.

Now that the two math geniuses S, P learned the numbers, it is right time that we, the readers, learn them too.

From the fact that his friend P could find the numbers, he draws the conclusion that only one of those equation systems has a valid solution. So, S is dying to find the product P, which, by the way, let's name "rare product" implying that it has the following property: only one of all pairs of numbers which have this product, has a good sum. If this sounds complicated, read until clear.

But S says that he found out the numbers. That can only mean that he has a sum that of all possible pairs which yield that sum, only one has a rare product.

What is therefore left for us, the readers, is to check all of the 10 possible sums to find the one that has a unique pair of numbers which give a rare product.

This is what the next piece of C code does:

#include <stdio.h>

int good_sums[]={11, 17, 23, 27, 29, 35, 37, 41, 47, 53};

int fuzzy(int x){ // determines the fuzziness of  x
   int i,j,s=0;

   for(i=2;i < 100;i++)
    for(j=2;j < 100;j++)
     if (x == i*j) s++;
   return s > 2;
}

int is_it_a_good_sum(int sum){ // determines the goodness :-) of  a "sum"
   int i=0;
   while( (good_sums[i] != sum ) && (i++ < 10) );
   return i < 10;
}

int rare(int G){ // determines if G is a rare product
   int i,j,s=0;

   for(i=2;i <= 99;i++)
    for(j=2;j <= 99;j++)
      if (G == i*j)
        if (fuzzy(G))
          if (is_it_a_good_sum(i+j))
            s++;
   return s == 2;
}

int main(){
   int i,x,one,tmp;
   for(i=0;i < 10;i++){
     x=2;
     one=0;
     do{
       one += rare(x*(good_sums[i]-x));  // this is the kind of code you have written
       if (rare(x*(good_sums[i]-x))) tmp=x;
       x++;                                              // a week before and now you see it again &
     }while (x+1 < good_sums[i]);          // you say: did I write that?! Am I an artist or what? :-)
     if (one == 2) printf("SUM = %d\n",good_sums[i]);
     if (one == 2) printf("PRODUCT = %d\n",tmp*(good_sums[i]-tmp)); 
   }
   return 0;
}
==> Program Ends Here <==

We are then presented with a humble:
SUM = 17
PRODUCT = 52
which reassures us that 17 is the one and only of all the 10 possible sums that of all pairs of numbers which sum to it (e.g. 5, 12 or 8, 9) only one has a rare product, i.e. a product which of all pairs of numbers which have that product only one has a good sum, i.e. a sum which all pairs of numbers which sum to it have fuzzy products. Oh, God, I said it...

So which numbers have a product of 52 and a sum of 17?
They are 4 and 13...

That's all folks, I hope you had a nice time!

Log in or register to write something here or to contact authors.