Everybody has some things that they want to keep secret, and here’s a question based on just that. I stumbled upon this fascinating little puzzle just yesterday, and wanted to share it, as I found it quite extraordinary. What would you say if there were 3 people who wanted to know the average salary of their trio and yet wanted their individual salaries to remain anonymous? This is assuming that there is no intermediary person or machine which can operate on the individual salaries of course, and there are just the three people and their communication. Well, as unlikely as it seems, there is a pretty awesome way to do this. As always, I have explained the solution below the picture, and so do scroll below only when you are ready to see the answer.
If each person doesn’t want their salary to be revealed, they will have to lie, or at least tweak their salary. First of all, let’s assume the three people as A, B, and C, and their real salaries a, b, and c respectively. What now?
To start with, A will tell B his salary a plus a random value xa. This maintains the anonymity that A wanted, and now B will take this fake salary, and add his salary b and again another random value xb, and tells it to C. C now takes this total and again adds his salary c as well as the random value xc, and then tells it to A. This total salary we now have (a + b + c + xa+ xb + xc) is completely off the target, and A has this useless total in his hands.
Now what does A do? He will now just subtract the random value xa that he had added before, which he remembers, and send this new total to B. B then subtracts his random value xb and send this total to C. What is this total? It’s simply a + b + c + xc. So now all C has to do is subtract his xc and now sends that to A, who now can reveal the true total of their salaries, and therefore the average salary of the trio. We now have found the average salary without any of the people having to disclose their salary to any of the others.
As you may be able to see, this can be generalized to any number of people for any such situation which requires people to remain anonymous. So next time a group of your parents are having a discussion about their weights… maybe you can try this out!