Re: If you can solve this your a genius
I think the answer is 2 and 6. I have modified some code from http://www.urch.com/forums/lounge/19...en-1-99-a.html
VB Code:
Option Explicit
Function P_knows(Product As Long) As Boolean 'Does P know the numbers?
Dim t As Long
Dim I As Long
t = 0
For I = 2 To roundUp(Sqr(Product)) 'Sqr to exclude the same numbers (e.g. 8 = 2 * 4 and 4 * 2)
If Product Mod I = 0 Then t = t + 1 'P doesn't know if you can divide it by more then one number
If t > 1 Then Exit For 'no need to check futher
Next
P_knows = t = 1
End Function
Function S_knows_that(Sum As Long) As Boolean 'Does S know that P can't know the numbers?
Dim iKnow As Long
Dim I As Long
For I = 2 To Sum \ 2 ' 2 to exclude the same numbers (e.g. 17 = 2 + 15 and 15 + 2)
If P_knows(I * (Sum - I)) Then 'for all the possible sums P should not be able to know the combination
'S_knows_that = False
'Exit Function
Else
iKnow = iKnow + 1
End If
Next I
If iKnow >= 2 Then
S_knows_that = True
Else
S_knows_that = False
End If
End Function
Function P_knows_now(Product As Long) As Boolean 'Does P know the two numbers after S knows that P can't know them?
Dim t As Long, I As Long
t = 0
For I = 2 To roundUp(Sqr(Product))
If Product Mod I = 0 Then 'P can only say that if there is just one combination
If I + (Product \ I) < 100 Then If S_knows_that(I + (Product \ I)) Then t = t + 1
If t > 1 Then Exit For 'no need to check futher
End If
Next I
P_knows_now = t = 1
End Function
Private Function roundUp(dblValue As Double) As Double
On Error GoTo PROC_ERR
Dim myDec As Long
myDec = InStr(1, CStr(dblValue), ".")
If myDec > 0 Then
roundUp = CDbl(Left$(CStr(dblValue), myDec)) + 1
Else
roundUp = dblValue
End If
PROC_EXIT:
Exit Function
PROC_ERR:
'MsgBox Err.description, vbInformation, "Round Up"
roundUp = CLng(dblValue)
End Function
Function S_knows_now(Sum As Long) As Boolean 'Does S know the two numbers too after P knows them?
Dim t As Long
Dim I As Long
t = 0
For I = 2 To Sum \ 2 'S can only say that if there is just one combination
If P_knows(I * (Sum - I)) = False Then
If P_knows_now(I * (Sum - I)) Then t = t + 1
End If
If t > 1 Then Exit For 'no need to check futher
Next I
S_knows_now = t = 1
End Function
Private Sub Form_Load()
Dim a As Long, b As Long
For b = 2 To 98
For a = 2 To 98
If a = 2 And b = 6 Then Stop
If a + b < 100 Then
' Debug.Print a; b,
If Not P_knows(a * b) Then
' Debug.Print "P knows not",
If S_knows_that(a + b) Then
' Debug.Print "S knows that",
If P_knows_now(a * b) Then
' Debug.Print "P knows now",
If S_knows_now(a + b) Then
' Debug.Print "S knows now",
MsgBox Format(a) + ", " + Format(b)
End If: End If: End If: End If: End If
' Debug.Print
' DoEvents
Next a, b
End Sub
The good people at microsoft say it is 4,13 :http://research.microsoft.com/aboutm...ns/2_XandY.htm
I think 2 and 6 work.
P = 12, S = 8
P => 12 = 3x4, 2x6 - so he doesn't know
S => 8 = 2+6, 3+5, 4+4 - so he doesn't know
P now knows because it can't be 3x4, if it was 3x4, the sum is 7
7 => 2+5, 3+4 But it can't be 2+5 or 3+4 because the Product guy would have known.
Now the Sum guy knows because it can't be 3+5. That is 15 and the Product guy would have know the first time. It also can't be 4+4, bacause the Product still wouldn't know. So it is 2,6
Re: If you can solve this your a genius
Two points:
1) The question given in post #1 and the one on the Microsoft page to which you have linked are not the same.
2) In your example, the fact that Y says that he knows X doesn't know does not then allow X to deduce what the numbers are.
Re: If you can solve this your a genius
Quote:
Originally Posted by Yonatan
Translation:
I know mn, but from my knowledge of mn and this knowledge alone, it is impossible to deduce what m+n is.
X has 52 but m + n could be 4 + 13 = 17 or 2 + 26 = 28
Quote:
Translation:
I know m+n, and from this knowledge I have been able to deduce that it is impossible to know m+n by just knowing mn.
Y has 17 and knows that every addition m + n that can make 17 gives an mn which could be found by multiplying together two different numbers (property 1)
Quote:
Translation:
I know mn, and I know that it should be impossible for me to find out m+n, but there is only one sum of two integers between 2 and 100 which make this impossible (which Yonatan didn't figure out yet), so I now know this sum!
Y couldn't have 28 because I could have 23 and 5 which are both primes and in that case I would know what m + n is, therfore Y has 17
Quote:
Translation:
Well, you figured them out! That means with your knowledge of mn and your knowledge that it's impossible to find m+n, there is only one possible sum - and with my knowledge of the sum and the knowledge that you have been able to figure it out, I have deduced that there is only one possible product, which I now know!
Out of my possibilities all but one could lead to another number similar to 17 (has property 1)
So if you know my number m and n must be 4 and 13 and therefore you have 52
Solution needs checking!
Re: If you can solve this your a genius
Quote:
Originally Posted by Glaysher
Y couldn't have 28 because I could have 23 and 5 which are both primes and in that case I would know what m + n is, therfore Y has 17
Yes but P knows he has 52, S can still have 28 which was made up from 2+26, 3+25, 4+24, 6+22, 7+21, 8+20, 9+19, 10+18 ...
Re: If you can solve this your a genius
Quote:
Originally Posted by THEROB
Yes but P knows he has 52, S can still have 28 which was made up from 2+26, 3+25, 4+24, 6+22, 7+21, 8+20, 9+19, 10+18 ...
But the point is that S knows that P doesn't know. He is certain of the fact. He couldn't be certain if there was the possibility that the number in question could be made up of two primes.
In the instance below, if S had 28 then P could have 23 x 5 = 115, and if P had been given 115 then he would know what m+n was. Hence if S had 28, he couldn't be sure that P didn't already know what the two numbers were.
Re: If you can solve this your a genius
Quote:
Originally Posted by zaza
But the point is that S knows that P doesn't know. He is certain of the fact. He couldn't be certain if there was the possibility that the number in question could be made up of two primes.
In the instance below, if S had 28 then P could have 23 x 5 = 115, and if P had been given 115 then he would know what m+n was. Hence if S had 28, he couldn't be sure that P didn't already know what the two numbers were.
Exactly and I have checked the solution though have not proved it's unique as that will be time consuming without a computer
Re: If you can solve this your a genius
So basically if the sum given to Y can be expressed as the sum of two primes then that sum is excluded from the set of possible values satisfying the situation..
So math guy X looks at his product and considers the possible sum of its factors.. If one of those sums could not 'possibly' be expressed as a sum of 2 primes (eg 2+7=9) then he takes special note of that thought because it is actually a pretty rare condition..
Now math guy Y slips the info that this rare condition is actually fulfilled by his sum, tipping off math guy X that the factoral sum he took special note of is indeed valid..
Meanwhile, math guy Y had taken special note that for one of the possible products, none of one of the possible sumations adding to his number could be expressed as the sum of two primes (the same rare condition)..
So when math guy X shoots off his mouth that he had the problem solved, he confirms to math guy Y that the special possible product he had taken note of was the only possible product X could have..
Edit: The true flaw in the logic I figure is the fact that one must assume another person has not made a mistake... Thats something I never like to do..
Re: If you can solve this your a genius
Sounds right.
Of course you have to assume X and Y are all knowing and logically sound