13 ms·
Reminds me of this problem: Two numbers are chosen randomly, both are positive integers smaller than 100. Sandy is told the sum of the numbers, while Peter is
by ninjinxo 4y ago
Reminds me of this problem:
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_cheryl_birthday_question/cqd7sus/ https://www.reddit.com/r/math/comments/32opae/next_level_che...
- CPLX 4y ago
- dmitriid 4y agoI still don't get it :D
- codetrotter 4y agoThis comment from the linked Reddit thread explains how: > 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.
- dmitriid 4y agoYeah, I read this explanation, and I'm probably being very dense, but I still don't get it :)
- yayachiken 4y agoTip: A simpler variant of essentially the same puzzle principle is the xkcd "Blue Eyes" puzzle. https://xkcd.com/blue_eyes.html https://xkcd.com/blue_eyes.html
- hashingroll 4y agoLove this! Took a while to find the solution :)
- ninjinxo 4y agoSince Peter is given the product of the two numbers, he should instantly know the pair if both numbers are prime, but since he doesn't it rules out pairs like (7x11) = 77 and (2x53) = 106. Sandy knows the sum and has now been told that Peter doesn't know the pair. If the sum had been 6, the following pairs are possible: (1+5) (3+3) (4+2), Peter has just ruled out (1x5) and (3x3), so Sandy would be able to narrow it down to (1,5) if the sum had been 6. So when she tells Peter she can't narrow it down, it tells him that the pair isn't (4,2) either (among many others). And if Peter's number were 8: (1x8) or (2x4) he'd be able to solve it, but he doesn't so Sandy then knows that (1,8) isn't the solution either.
- informal007 4y ago>since he doesn't it rules out pairs like (7x11) = 77 and (2x53) = 106. I think pair (7x11)=77 can't be rule out, because pair (1x77) is also equal 77. still don't got it... Can you explain the situation for 3 turns before Peter knows, Sincere thanks.
- herendin 4y ago
- quickthrower2 4y agoA smaller variant if that puzzle is in the article.
- jancsika 4y agoCVE-2022-123456: The specification doesn't require each new round to be dependent on the input from the previous round. This can allow unprivileged users to send arbitrary commands to the accelerator and breaking system.
- vivegi 4y agoPeter: I know the product and it is p.q Sandy: I know the sum and it is p + q Peter and Sandy (in unison): Got it! 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!
- dromedariusCase 4y agoCutest problem I've ever seen. If anyone still doesn't understand, it basically comes down to removing "unique" products and sum from the possibility space. Here is some python code that might be more revealing https://www.online-python.com/c5nAfLoIqr https://www.online-python.com/c5nAfLoIqr A code review would be greatly appreciated!
- mcv 4y agoThat's an elegant way to do it. For a brief moment I considered solving this by hand using basically the same idea, but that gets incredibly painful before I even got started. I mean, obviously the extremes get eliminated right away, and then the primes, but then I have to track 10,000 number combinations.
- dromedariusCase 4y agoI originally also thought about doing this (sort of) by hand, but once you realize that the possibility space is too large, programming it really helps you see what kinda pairs you are actually eliminating. 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.
- bperlman 4y agoI'm confused: If Sandy tells Peter her sum, why doesn't Peter use the quadratic formula to solve for the x,y pair algebraically? 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 = -1s c = p y_solved = (-1b + (b*2 - 4ac)*.5)/(2a),(-1b - (b*2 - 4ac)*.5)/(2a) print(x,y,y_solved)
- wice 4y agoThat's the point, Sandy doesn't tell Peter her sum, nor vice versa. Sandy only knows the sum, Peter only knows the product, and they both know that the other doesn't (yet) know the answer. It allows them (in turns) to eliminate all the pairs that produce unique sums/products, until Peter ends up with one single pair.