Before you can solve the puzzle, you need to determine the entering and leaving sequence for each of the houses. Label the houses as follows:

Recall the rules the prisoner gave you: enter each house twice and leave it once. Enter house A eight times and note where you leave from each time. Open the door to house E to reset the system.

Now do the same thing for house B, C and D. After the eight moves you can keep going into each house but you will only come out the same door again. Your results should be the same as mine:

House A | House B | House C | House D |

A - A | B - E | C - D | D - B |

A - C | B - B | C - A | D - A |

A - E | B - E | C - C | D - B |

A - C | B - A | C - D | D - D |

A - E | B - D | C - E | D - C |

A - A | B - B | C - B | D - C |

A - B | B - A | C - C | D - D |

A - D | B - E | C - A | D - C |

The next bit needs a bit of thought. If you look at the results you will see that on moves 1, 3, 5 and 8 you can leave house E. This means you only need to work out 4 moves (2, 4, 6 and 7).

With me so far? Moves 1, 3, 5 and 8 must be: B-E, A-E, C-E and B-E. Since you have now already entered house B twice, in the other 4 moves you need to enter house A once, house C once and house D twice.

And so by a process of elimination one sequence is:

B-E, D-A, A-E, A-C, C-E, C-B, D-D, B-E.

Another sequence is:

B-E, C-A, A-E, D-D, C-E, D-C, D-C, B-E.

Simple really. It still took me ages to work it out though.

If you have found this walkthrough useful, discovered an error or have a suggestion then let me know: feedback.