The number of doors in the house is 3, so there are three ways of entering the house. Also there are three ways of leaving through any one of the doors. Now each of the four guests has 3 ways of coming in, so the total number of ways is 3*3*3*3 = 3^4 . Similarly the number of ways of leaving for all the four is 3^4. Therefore the number of ways in which they can come in and leave is 2*3^4 = 162
The required result is 162.
For only one 1 person the choice is 3 ways.
For only 2 persons (A and), AEach has 3 choices. For any one ofthe way A goes , B has 3choices. So for each of 3 choices of , the other has 3 choices. So in all for 2 persons, 3*3 = 9 ways are there.
Like wise we can extend for number n persons and m doors , they could exit in n^m ways
In this case n = 4 and m= 3:
Since each of the 4 guests is independent to take any of the 3 ways, irrespctive of what the other choses, the number of ways is
3*3*3*3 = 3^4 = 81..