2 Aug 2013

The Nine Rooms Puzzle (PMQ29): Answer and Solution


The original question can be found at The Nine Rooms Puzzle (PMQ29).

Guided Solution

As is often the case, let’s look at one example first, then see how to proceed to the full solution. The original question was accompanied by a rather helpful diagram (that I have helpfully copied), so let’s start there.

Firstly, let’s assign a number to each door. The actual order does not make any difference to the final probability but, as the question mentions that our hapless subject has a map, the door numbers are known before the dice are rolled. I have numbered them in sequence going from left to right and downwards. The path shown in the diagram is therefore [1-2-5-7-6-8-11-12]. Notice that, to visit all nine rooms requires going through 8 doors, leaving 4 doors unused. These 4 unused doors form the set (3, 4, 9, 10). Therefore, if our prisoner player rolls any 2 of these 4 numbers, he will still be able to complete this particular path and win. Rolling anything else means he cannot take this precise route; he may, of course, be able to use another winning route, but we’re coming to that in a minute.

The first thing to calculate are his winning rolls for this particular solution. Needing 2 numbers out of 4 gives us 12 permutations, but in this case we’re not interested in the order of the dice so there are just 6 winning combinations. These are: (3, 4), (3, 9), (3, 10), (4, 9), (4, 10) and (9, 10). So, we have found 6 winning rolls that enable our player to win. How many more are there?

We now need to list all the possible winning routes. If we start and finish at the same two points in the diagram, note that there is a second possible route: [3-8-11-9-4-2-5-10]. This gives us the set of unused doors (1, 6, 7, 12) and another 6 winning rolls.

Also note that, starting at the same top-left cell, our player must finish his route in one of four cells: either one of the other three corners or the centre cell. There are also two routes to each of those ending cells, making a total of 8 winning routes. Try drawing each of them and you will see which doors are unused for each route.

At this point, we could rush headlong into a wrong answer; multiplying 6 winning rolls for each of 8 winning routes gives us 48 winning rolls in total. However, this is hugely optimistic!

I am not going to go through the whole table (I suggest at this point to make a table so that you don’t count the same dice roll twice) as you may well be getting slightly different numbers depending on how you labelled the doors. However, one more example, to prove our earlier folly. If we take a clockwise route and end in the central quad, we have the sequence [1-2-5-10-12-11-8-6], leaving us the set (3, 4, 7, 9) of unused doors. But, compared with our very first route, we have three of the same four doors unused. This means that the only distinct new winning rolls are (3, 7), (4, 7) and (7, 9).

If you carry on this analysis, you should end up with 29 distinct winning dice rolls. There are only 8 winning routes, so this enumeration doesn’t really take very long.

In fact, at this point, I overlapped all the winning routes to see whether some doors were more important than others; indeed, using my numbering, doors 7 and 9 are almost "phantom doors" in that they are rarely needed, which means rolling at least one of those numbers almost guarantees a win. OK, this is maths, so let's quantify this; even at the risk of going off at a tangent! If the player rolls a 9, the only losing rolls are (9, 11) and (9, 12); you can see that such rolls effectively render the lower-middle cell a dead-end. Similarly, the only losing rolls with a 7 are (7, 5) and (7, 10); again the middle-right cell becomes a trap. So, rolling a 9 or a 7 gives a losing probability of just 4/23. Once you see the final answer, you too will think such odds miraculous.

Lastly (or possibly firstly, as this is the easiest bit), the total number of possible rolls is 12x11/2=66. Remember, as we need to slam shut exactly 2 doors, the question states that the player cannot roll the same number on the two dice, hence there are 66 valid rolls and not 72.

And finally, the probability that our player is successful in picking up the nine gold coins and being teleported to Never-Never Land is 29/66 – less than half. The question doesn’t mention what happens if he fails.

The Answer

The probability of success is 29/66.

The Roll of Honour

Well done to Chad Kemp for posting the correct answer in the comments to the original question. There were no PMQ winners by email.