Not applet capable!

Mastermind Solver

  1. Uses six letters instead of six colors.
  2. Input a puzzle (e.g. "bfab") and press <Enter>.
  3. The solver starts by picking a random letter and its succeeding neighbor. Each letter is guessed twice.
  4. After the answer is computed, pressing <Enter> again will solve the same puzzle again. If a different random letter is chosen, the answer will take a different path.
The solver uses the following four rules:
  1. If "black + white = 0", then each letter in the guess should be eliminated from every slot.
  2. If "black = 0", then each letter in the guess should be removed from the position it holds in the guess.
  3. If "black + white = 4", then start guessing permutations of the current guess.
  4. A potential guess is invalid if it contradicts feedback from any previous guesses.
The implementation is a state machine with four states:
  1. GuessOne - pick a randow letter and its succeeding neighbor
  2. GuessTwo - pick the next two neighbors
  3. GuessCompute - cycle through all remaining combinations (like an odometer), applying rule 4 before submitting each guess
  4. GuessPermute - cycle through all permutations, applying rule 4 before submitting each guess
GuessOne and GuessTwo issue a single guess each. GuessCompute keeps guessing until rule 3 applies and GuessPermute is made the current state.