algorithm - The perverse hangman problem -


The perverted executioner is a game played on a regular basis like a tremendous executioner: the winning word is a dynamic form Determines whether the letter has been estimated.

For example, you have the board _ AIL and 12 remaining estimates because AIL (collateral, fail, jay, jail, call, mail, nakhle, falcon, train, pal , Tail, cover, moan) because it is guaranteed to win because 12 characters have no meaning, the house will claim that the chosen word does not mean for you. However, if the board was _ ILM , then you have rotated the house because the film is the only word that ends in the ILM.

The challenge is: looking at a dictionary, the length of one word is & amp; The number of permitted estimates come with an algorithm that:

a) This proves that the player always wins by producing a decision tree for the player, which is not the difference in the corner of the house

B) It proves that the house always wins by producing a decision for the house which allows the house to escape.

As a toy example, consider the dictionary:

  bat bar car  

If you allow 3 wrong estimates , Then the player must win with the following tree:

  not estimate B -> Seems to be C, seems to be an estimate, r, win yes-> T number estimate - & gt; Seems A, Estimated R, Win Yes-> This estimate is almost identical "How do I find weird?" Repeated coin coin? "Trouble. The fundamental insight is that you are trying to maximize the information you get from your estimation. 

The greedy algorithm for making a decision tree is as follows: - Estimate for each estimate For which the answer is "true" and the answer that is "false" is as close to 50-50 as much as possible, as theoretically it gives the most information.

Let's set the size Yes, come alphabetically , And the number of letters in the letter L.

Then put all your words in one set. For each letter's position, and how many words in this number for each letter in your alphabet These numbers (this can be customized with an additional hash table) select the count which is closest to the size of the half-set. This is O (L * A).

Set in two Let's split this letter in this situation Take a subset of, and make the tree two branches, repeat for each sub-group until you have the whole tree. In the worst case scenario, it will be required (O) phase, but if you have It's a good dictionary, so it will take the logen steps.


Comments

Popular posts from this blog

c# - How to capture HTTP packet with SharpPcap -

php - Multiple Select with Explode: only returns the word "Array" -

php - jQuery AJAX Post not working -