Skip to content

Instantly share code, notes, and snippets.

@thunklife
Last active June 20, 2019 20:55
Show Gist options
  • Save thunklife/14fb6b1a9d58b0e3bf8751bb4e139348 to your computer and use it in GitHub Desktop.
Save thunklife/14fb6b1a9d58b0e3bf8751bb4e139348 to your computer and use it in GitHub Desktop.

Mastermind

Description

Mastermind is a boardgame with 2 players, the code maker and the code breaker you are the code breaker. The code maker creates a code using 4 colored pegs in any order they wish. The code breaker attempts to guess the code in 12 turns. With each turn, the code breaker is given two pieces of information: 1) The number of exact matches 2) The number of color matches.

A Few Details

  • Colors can be repeated, a code does not have to contain all colors.
  • Valid Colors: Red, Green, Blue, Yellow
  • Valid Codes [Red, Red, Red, Red], [Blue, Green, Yellow, Green]

The Challenge

Create a code and create a function that will take guess and see if it matches the code you created. Remember the code breaker only gets 12 guesses, but they can use the informantion from the previous guess to refine their current guess.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment