I have this numbers teaser:
There exists 2 integers $x $ & $ y$, such that $x\geq y$.
Alice knows the value of $x+y$, and Bob knows the value of $x^2 + y^2$.
The following conversation happens between Bob and Alice.
Bob: I don't know the numbers
Alice: I don't know the numbers
Bob: I don't know the numbers
Alice: I don't know the numbers
Bob: I don't know the numbers
Alice: I don't know the numbers
Bob: I know the numbers.
What are the values of $x$ and $y$ ?
I have been also told that $x$ and $y$ do not exceed 25 each, and that there is a unique answer to this problem.
Does anyone know how it is solved?
Approach: I did try to solve it as this comment suggested, however i couldn't reach a specific value at the end. (Please note this code was written in iPy)
Here is my code:
from itertools import product
options = [(x,y,x+y,x**2+y**2) for x,y in product(range(1,26),repeat=2) if x >= y]
for i in range(100):
if i%2==0: #Bob
j=3
else: #Alice
j=2
op = []
for o in options:
if len([k for k in options if k[j]==o[j]])>1:
op.append(o)
options = op
display(len(options),i)
if len(options) <= 1:
break
display(options,i)
Assuming $x$ and $y$ are integers in the range $1$ to $25$... Hint:
It is a finite (though not exactly small) problem, so instead of doing it by hand, leave it to a computer to comb through those pairs.