This question already has an answer here:
- Write a Hangman Solver 8 answers
Please do not delete this without reading it completely. Put it in unclear if there are some questions. I will respond immediately. This is different from the question "Write a Hangman Solver" because of the way of inputs plus there is a lot of difference in the algorithm required there are no limitations on the length of the code but the time required for 50000 words is limited to 60 seconds. (please solve this and mark it as non duplicate)
Given the attached 50,000 words dictionary, write a program that can play hangman by choosing a letter based on the current state of the board. A board would initially have a series of blanks, each representing one letter in the word. As letters are guessed, all spaces in the word that match the letter should be replaced with that letter. Any letters that have no matches are put on a list of missed letters. Once the list of missed letters reaches 6, the game is lost.
State assumptions and trade-offs made.
Write a driver program that takes the word as a command-line argument and shows the board after each step as well as ultimate outcome. The guesses should come from the program, not from user input.
./hangman hangman _ _ _ _ _ _ _ missed:
guess: e _ _ _ _ _ _ _ missed: e
guess: a _ a _ _ _ a _ missed : e
guess: n _ a n _ _ a n missed: e
guess: m _ a n _ m a n missed: e
guess: d _ a n _ m a n missed: e,d
guess: k _ a n _ m a n missed: e,d,k
guess: g _ a n g m a n missed: e,d,k
guess: h h a n g m a n missed: e,d,k
As a final step, you should run all the words in the dictionary as inputs to your program and show us the percentage of the words matched correctly.
Your program will be evaluated on the following metrics:
What percentage of the words was correctly guessed by the compiler. Time constraint: 60 seconds
Please have your program generate the following output:(sample output)
Number of words tested: 50,000 Number of words guessed correctly: 40,000 Correct Guesses (%): 80.0%