Puzzle of the Week #231 - Mastermind

You may be familiar with the game ‘Mastermind’, where one player forms a code of coloured pegs and another makes guesses. The coder tells the guesser after each guess how many pegs are fully correct, and how many others are present but in the wrong place.

My version is different from the standard version in three respects:

a)    Instead of four, the code is now FIVE pegs long.

b)    Instead of six different colours to choose from, in this version there are only TWO different colours of pegs: RED and YELLOW. There are therefore 2 to the power of 5, (32), different possible codes the coder might have set.

c)    The guesser has decide what their first ‘n-1’ guesses are going to be straight away, before getting any feedback from the coder, such that when the feedback ultimately comes, the guesser can be certain of guessing correctly on the very next guess, the ‘nth’ guess (or earlier if one of the original n-1 guesses happened to have been correct). (In other words, if the guesser decides on 9 guesses and knows that whatever the code happens to be, they can use the feedback from those 9 guesses to be certain that the 10th guess will be correct, then n equals 10).

 

The question is then: what is the minimum value of ‘n’, such that the nth guess is guaranteed to be correct?