What is Evil hangman?
Evil hangman looks like the standard game from the guesser's side: a row of blanks, one letter per guess, and a figure that grows with every miss. The difference is on the other side of the table. The computer does not choose one secret word at the start. It fixes only the length, and keeps every word from its list with that many letters as a possible answer.
When you guess a letter, the computer sorts the words still in play by where that letter would appear in them: words without it, words with it in the first place only, words with it in the second and fifth places, and so on. It keeps the largest of these groups and answers your guess to match it. If the largest group is the one without your letter, the guess is a miss; otherwise the letter appears exactly where every word in the group has it. Each answer is honest, because at least one real word fits everything shown so far, but the computer keeps its options as open as it can for as long as it can.
To beat it, you need guesses that split the remaining words evenly, so that even the largest group is small. Common letters that appear in many places are often worse than they look.
Rule changes
| Rule | Standard Hangman | Evil hangman |
|---|---|---|
| The secret word | Standard HangmanThe word picker chooses one word before the first guess and keeps it to the end. | Evil hangmanOnly the length is fixed at the start. Every list word of that length stays a possible answer until the guesses rule it out. |
| Answering a guess | Standard HangmanThe letter is shown wherever it appears in the chosen word, or the guess is a miss. | Evil hangmanThe computer groups the words still in play by where the letter would appear in them and answers for the largest group. |
| Groups of equal size | Standard HangmanDoes not arise. | Evil hangmanA group without the letter wins the tie, so the guess is a miss; then the group that shows the letter fewer times; then the one that shows it earliest in the word. |
| The word at the end | Standard HangmanThe word chosen at the start. | Evil hangmanA word from the last remaining group. It always fits every letter shown and every miss. |
| Who picks the word | Standard HangmanEither player, or the computer from its word list; a human may type any word of 3 to 20 letters. | Evil hangmanThe computer, from its word list, because only it can keep the whole group in mind. You play the guesser against it. |
| Other options | Standard Hangman6 lives, any word length, words from the general list and no clock. | Evil hangmanThe other options can be set alongside it: 8 or 10 lives, short, medium or long words, a word category, which shrinks the list the computer keeps, and a clock for each guess. |
History
Evil hangman is best known as a programming exercise. Keith Schwarz of Stanford University presented it under the name Evil Hangman among the Nifty Assignments at the SIGCSE computer science education conference in 2011, as a task for students learning to work with collections of data: the program must keep track of every word that is still possible and split it into groups after each guess. Many university courses have since set their own versions of the assignment.
The idea of an opponent who delays committing to an answer is older than the exercise, and it belongs to the guessing game rather than to any one author. The tie rules on this site, which favour a miss, then fewer letters shown, then the earliest places, are this site's own choice, made so that every game can be replayed exactly.