72 points · by nsoonhui · 4y ago · 56 comments
Two numbers are chosen randomly, both are positive integers smaller than 100. Sandy is told the sum of the numbers, while Peter is told the product of the numbers.
Then, this dialog occurs between Sandy and Peter:
Peter: I don't know the numbers.
Sandy: I don't know the numbers.
Peter: I don't know the numbers.
Sandy: I don't know the numbers.
Peter: I don't know the numbers.
Sandy: I don't know the numbers.
Peter: I don't know the numbers.
Sandy: I don't know the numbers.
Peter: I don't know the numbers.
Sandy: I don't know the numbers.
Peter: I don't know the numbers.
Sandy: I don't know the numbers.
Peter: I don't know the numbers.
Sandy: I don't know the numbers.
Peter: I do know the numbers.
What are the numbers?
Source: https://www.reddit.com/r/math/comments/32opae/next_level_che...
Here is some python code that might be more revealing https://www.online-python.com/c5nAfLoIqr
A code review would be greatly appreciated!
I mean, obviously the extremes get eliminated right away, and then the primes, but then I have to track 10,000 number combinations.
You can actually WLOG away all pairs where the second element is larger than the first.
Also, the most common kind of pair I eliminated was actually due to the size constraint (ie, 98 * 99) or pairs of (1, prime) which I didn't actually realize would be a thing until I coded it up.
another variant:
Peter: If I divide by 4, I have remainder x Sandy: If I divide by 4, I have remainder y Peter: If I divide by 25, I have remainder a Sandy: If I divide by 25, I have remainder b Peter and Sandy (in unison): Got it!
x + y = s
x * y = p
x = s - y
x = p/y
substitute for x
p/y = s - y
p = sy - y*2
y*2 - sy + p = 0
# use the quadratic formula to solve for y
y = (-b ± √(b²-4ac)) / (2a)
In python:
import numpy as np
x = np.random.randint(1,100)
y = np.random.randint(1,100)
s = x+y
p = xy
a = 1
b = -1
sc = p
y_solved = (-1b + (b*2 - 4ac)*.5)/(2a),(-1b - (b*2 - 4ac)*.5)/(2a)
print(x,y,y_solved)
> Each sentence is extra data given to the other person.
> When Peter says "I don't know the numbers", means that he doesn't have enough information. For example, if the product of the numbers is 10, it could be (1,10) or (2,5). But if the product is 9801, then Peter would know the answer (99,99). Therefore, his first sentence reveals to Sandy that (99,99) isn't a possible answer. But even this extra data isn't enough for Sandy to know the answer, and she says so. Again, this is extra data for Peter, but , again, is not enough. This go back and forth until suddenly Peter gains enough information to find the answer.
[0] https://web.archive.org/web/20121228075545/http://devblog.bu...
I started hacking on this protocol using a pencil and paper variation of Diffie-Hellman where instead of a secret key agreement you arrive at the same salary number (as a function of the difference in your secret numbers), but realized you can do a one-sided version of this where the potential employee says to the recruiter "think of your max budget for this role" using a variation the second puzzle in article, though unfortunately the recruiter would likely feel tricked, so I've gone back to working on a DH-like protocol ahead of time because it would be fairer.
Of course I would have liked to have made a blog post out of it, but this article is so close and mine is still half-baked, so if someone beats me to it and wants to leverage the power of being wrong on the internet in this comment thread, we could create a fair protocol that improves the lives of all parties involved in the hiring process.
https://en.wikipedia.org/wiki/Yao%27s_Millionaires%27_proble...
It'd be interesting to see if any of the tricks worked for, say, -7π + ei.
Such a loop of operations containing only multiplication, addition, and subtraction would work on activity complex numbers. Square roots would not.
Spoilers:
First note that, below 16, 11 is the only sum which explains S's first statement: all possible pairs of numbers adding to 11 have non-unique products, accounting for S knowing P would not know the numbers.
Then note that for 18 (9x2), 24 (8x3), and 28 (7x4), all other factor pairs for that product add to a non-11 number below 16. Those non-11 sums are ruled out by S's first statement, so P will know the sum is 11 by her second statement.
Therefore (9,2), (8,3), and (7,4) all look like valid solutions, and it seems likely there are more.
What am I missing?
https://web.archive.org/web/20121228075545/http://devblog.bu...
Any positive integer you take, you end up in a 1-4-2-1 loop. It's not proved yet but there's no number found yet that satisfies otherwise.
Very interesting. What's the use case of this?
Impressing ladies at the bar with your 'deep connection'.