0
\$\begingroup\$

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%

https://gist.github.com/anonymous/535f0e844a7746cab9679fbe2ed7c68f

\$\endgroup\$
10
  • \$\begingroup\$ it is not possible to get 100% accurate results @DJMcMayhem also the time constraint is 60 sec \$\endgroup\$ Sep 17, 2016 at 17:29
  • \$\begingroup\$ is it fine now @DJ \$\endgroup\$ Sep 17, 2016 at 17:29
  • \$\begingroup\$ I'm sorry, I didn't read it carefully enough. Yes it's better, and I was also going to recommend taking out the How clearly is the program written, but you already did. \$\endgroup\$
    – DJMcMayhem
    Sep 17, 2016 at 17:32
  • 1
    \$\begingroup\$ 50k words and 60 seconds per guess is silly. An optimal algorithm is going to run in a fraction of a second over such a small list. \$\endgroup\$
    – Sparr
    Sep 17, 2016 at 18:14
  • 1
    \$\begingroup\$ Um, command line input? Not a fan of that rigid input \$\endgroup\$ Sep 17, 2016 at 19:01

0

Browse other questions tagged or ask your own question.