Monday, January 01, 2007

Salaries of three persons

There are 3 persons A,B,C and their salaries are X, Y, Z respectively.

Problem: Device a scheme so that all three of them know X+Y+Z, by asking each other questions.

Constraint: None should come to the other one's salary, i.e. A should not know Y and Z and so on...


===============================================

Solution:

C tells B that its salary is K (a fake value)
B tells A the total K+Y
A tells C the total K+Y+X
Finally C calculates X+Y+Z and tells it to everybody.


No comments: