Sunday, 1 May 2011

Salary

Question: 4 persons are sitting in dinner table taking lunch .They are working in the same company.They do not know the salary of each other.They can not disclose the salary.
what is the way to know the salary of each person?....
-------------------------------------------------------------------------------------------------------
Answer:
A , B , C,D are 4 person
A gives a random number to B=a1
B gives a random number to C=b1
C gives a random number to D=c1
D gives a random number to A=d1
Since A knows his salary i.e. a
so
 A will know B's Salary by= a+d1-a1;
similarly

Since B knows his salary i.e. b
so B will know C's Salary by= b+a1-b1;
Since C knows his salary i.e. c
so C will know D's Salary by= c+b1-c1;
Since D knows his salary i.e. d
so D will know A's Salary by= d+c1-d1;


X and O

Question:
 The game of Tic -Tac-Toe is played in a large square divided into nine small squares
1.Each of the two players in turn places his or her mark -usually X or O -in  a square.
2.The player who first gets three marks in a horizontal,vertical,or diagonal line wins.
3. A player will always place his or her marks in a line that already contains  (a)Two of his or her own marks
or (b) two of his or her opponent's marks- giving(a) priority  over (b)


X  1
O 2
3 
X 4
      5 
6 
O 7
O 8
X 9


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

Answer:
We have to find
 1.  Who will take the next move (either X or O)
 2. Where will the next move in the square takes place.
Here we will find  who had make the first move.
The cells are marked as 1,2,3,4,5,6,7,8,9

Here the next move will be in the cell 5 (either X or O)

The optimal solution is
*********************************************************
The first move is O at 2.
Next move will be X at  4.
Next move will be O at 7.
Next Move will be X at  1.
Next Move will be O at 8.
Next Move will be X at 9.
So next move will be O at 5 .and he will win
*********************************************************