Some interview Puzzles

You are locked inside a room with 6 doors - A, B, C, D, E, F. Out of which 3 are Entrances only and 3 are Exits only.
One person came in through door F and two minutes later second person came in through door A. He said, "You will be set free, if you pass through all 6 doors, each door once only and in correct order. Also, door A must be followed by door B or E, door B by C or E, door C by D or F, door D by A or F, door E by B or D and door F by C or D."
After saying that they both left through door B and unlocked all doors. In which order must you pass through the doors?

Answer
The correct order is CFDABE
It is given that one person came in through door F and second person came in through door A. It means that door A and door F are Entrances. Also, they both left through door B. Hence, door B is Exit.
As Exit and Entrance should alter each other and we know two Entrances, let's assume that the third Entrance is W. Thus, there are 6 possibilities with "_" indicating Exit.
(1) _W_A_F (2) _W_F_A (3) _F_W_A (4) _F_A_W (5) _A_W_F (6) _A_F_W
As door A must be followed by door B or E and none of them lead to the door F, (1) and (6) are not possible.
Also, door D must be the Exit as only door D leads to the door A and door A is the Entrance.
(2) _W_FDA (3) _F_WDA (4) _FDA_W (5) DA_W_F
Only door D and door C lead to the door F. But door D is used. Hence, door C must be the Exit and precede door F. Also, the third Exit is B and the W must be door E.
(2) BECFDA (3) CFBEDA (4) CFDABE (5) DACEBF
But only door B leads to the door C and both are Exits. Hence, (2) and (5) are not possible. Also, door F does not lead to door B - discard (3). Hence, the possible order is (4) i.e. CFDABE.

No comments: