The **passtune** is the 5-note tune that opens the castle drawbridge. It is composed of the 7 diatonic notes: A, B, C, D, E, F, G. H is also accepted, and is equivalent to B; this comes from German musical notation, in which B is called H and B flat is called B.

It can be given to you by your god when praying, or discovered through a game of mastermind. Playing a tune on a musical instrument when standing near the drawbridge will give you a clue: hearing a tumbler click means you have a correct note in the wrong place, and hearing a gear turn means you have a correct note in the correct place.

## The brute force solutionEdit

The most intuitive way of solving is to use 7 guesses to discover what notes are in the passtune:

AAAAA BBBBB CCCCC DDDDD EEEEE FFFFF GGGGG

You may not need to use all these guesses to discover how many of which notes you need (in fact you will need at most 6: if you know the tune contains only A's after trying down to FFFFF, then it must also contain a G).

Imagine you have discovered the passtune contains an A, a B, a C, and 2 G's.

Choose an unused letter, D, and try to find where the A is:

ADDDD DADDD DDADD DDDAD DDDDA

If the fourth guess here yields a turning gear, you know the A must be in the fourth position. Repeat this process for B, but with the known A in place:

BDDAD DBDAD DDBAD DDDAB

If the first guess here yields two turning gears, you know the B must be in the first position. Repeat this process for C, but with the known A and B in place:

BCDAD BDCAD BDDAC

If the third guess here yields three turning gears, you know the C must be in the third position.

Because G is present twice, you know that the remaining two unknown letters must both be G, and so the passtune is BGGAC.

This method uses at most 16 guesses.

## The slightly clever solutionEdit

The idea here is the same as above, but you make guesses as you discover information, as shown in the example below:

First guess AAAAA. If no gears turn, try BBBBB, then CCCCC, and you will find a letter which is present in the solution, say, A.

Now guess that A is in the first position, and try to discover whether the solution contains B:

ABBBB

If two tumblers click, the first position must be B, so next guess that A is in the second position and that there are C's:

BACCC

If two tumblers click and one gear turns, the second position must be C, so next guess that A is in the third position and that there are D's:

BCADD

If one tumbler clicks and two gears turn, you know the A can't be in the third position and that there are no D's, so try:

BCEAE

If one tumbler clicks and two gears turn, you know the A can't be in the fourth position and that there are no E's, so try:

BCFFA

If three gears turn, you know there are no F's, so the solution must be:

BCGGA

This method is faster than the intuitive one, but requires some thought.

## The best solutionEdit

A number of schemes for solving general mastermind games are known, such as this one, which requires random guesses, but on average only a small number of them.

## External linksEdit

- Opening the Castle's Drawbridge playing Mastermind — An online passtune solver
- wikipedia:Mastermind (board game)
- Botting NetHack's Mastermind