Data storage for the program of the evil executioner

I need to write an executioner program. Only the "house" is evil and changes the word, so the player (hopefully) loses.

I will create a set of all words at the beginning of the game, when the player selects a letter, I will create a set that matches the template, and continue to create the optimal subset.

eg

Assuming the user selects 3 alphabetic words, and for these examples, we say that in English there are only the following 3-letter words; Dog Fog And Fox Cat Not Bus

If the user Guesses is "o", the program will compile a list of words with "o" in them, I will sort this list into sets so that one set is "and" another "bus" and the other is cat "

However, I was wondering what the best way would be to store these sets.

+4
source share
2 answers

As a suggestion, think about what operation you need for effective support. You will need to be able to take a word, compare it with your family of words, and from there, to extend this word to a collection of words corresponding to this family. To do this, consider using something like Map , which will associate a family of words (represented as you like) with a collection of words corresponding to this family. You can present a collection in many ways - like Set , like List , etc. Thus, you can easily take a string, convert it into a family of words, and then map the family of words to the set of all the words in this family.

Hope this helps!

+2
source

Let me rephrase what you are doing:

  • You have a set of words for the specified length.
  • Each time the user specifies a character, you want to remove from the current set all words that contain this character without emptying the set.

Optional to be even more evil:

  • If your set is now empty, you want to select from your original set of words the largest subset of words with the specified character in the same index.

Is that what you want to do?

If so, I would think that you are going to do a lot.

Given a text file containing a large list of words. First I would have to make a list of word sets separated by the length of the character.

After duplicating this set, you can start asking the user for specific characters. Since characters are provided, you must remove the words in the set that contain that character.

So, as you can see, the naive approach to solving this issue was to iterate over all the words in the set and iterate through the characters to see if it contains the specified character.

It would be best to spell words with the characters that they contain. Good luck

+1
source

All Articles