mastermind-stream

by bh
See Code Download Embed
One player thinks of a secret combination of four distinct colors from the set red (r), orange (o), yellow (y), green (g), blue (b), and violet (v).

The other player must guess a combination of four distinct colors.  The first player then indicates how many correct colors are in the correct positions, and how many correct colors are in incorrect positions.

For example, if the secret combination is bryg and the second player guesses bgyv, the first player will respond "2 1" because blue and yellow are in the correct position, and green is in the combination but in the wrong place.

When you start the program with the green flag, you can choose to be the first player, thinking of a secret combination and responding to the computer's guesses (S), or to be the second player and guess the computer's secret combination (G).

If you make every guess count, you should always be able to win in seven guesses!

Created July 4, 2014

Last updated July 31, 2024

Published July 31, 2024