In the applet bellow the number of exact matches is indicated by small red dots, while white dots define the second number. In the real game the codemaker uses small pegs for the same purpose. Mastermind is a game of deduction. When only one element remains it is bound to be the secret code. If colors are represented by numbers starting with 0, then 0011 or 0012 are good candidates for the first guess.
Mastermind relates to the language and body of mathematics in other respects too.
If a guess contains the same color in more than 1 position, but the secret code contains it only once, an interesting situation may arise. Evaluation of exact matches has precedence over evaluation of near, or color, matches. Accordingly, in the example there is 1 exact match and no color matches. The total number of color matches is the sum of matches for all individual colors. We suggested above that 0011 would be a good starting guess.