This is Hulu programming challenge, Hangman game.
- Please directly import this project to IDE IntelliJ IDEA.
- Change URL_PREFIX to your Hangman web service.
- Run HangmanRunner
- Firstly I downloaded a frequency word list, which contains two element each line. First element is 'word', second is the frequency for this word.
- Then I build a HashMap to store all the words. Key is the length of the word, value is a HashMap (key is the word, value is its frequency). In this way, I could find the most likely words given certain pattern.
-
If all the words are underscores pattern, choose the shortest one. ex(__ ___ ____), choose '__' as the guessing pattern.
-
If some words contains letters that have been guessed out. Choose the one with highest known rate. (calculated by : known/unkown)
- I S C_ : choose '_S'
- I S COO : choose 'COO'
-
If several words' known are the same, choose the longest one.
- HI S C__ : choose 'HI'
- I LL ____ T F RE___EE : choose 'RE___EE_'
Choose all the candidate words that matches the pattern of this target pattern
Then choose target word with the highest frequency in the candidate word list. Then choose the target letter from with the highest frequency among all the missing words in this pattern.