Search for a word from a given dictionary by several known letters

A dictionary of words of different lengths (approximately 1500 words) is given. The input is given several letters (from 3 and more). The order of the letters in a word may be unknown, or it may be known that the given letter is ahead of the others (the order of the others is unknown).

Tell me the algorithm for finding all the appropriate words from the dictionary?

Author: Kromster, 2018-11-25

1 answers

You can add a bit field to each word in the dictionary, which will contain the bits of the letters included in the word. For example, for the Russian language and the word "Abya", the value will be 11000..0001. Next, when searching, make such a bit field of the entered letters (for example, entered aya, will be 1000..0001) and compare with the field in the dictionary by И. If the value is equal to the field, then all the letters in the word are there.

The search rule for "this letter is ahead of the others" is not entirely clear, please specify.

 0
Author: Kromster, 2018-11-30 05:05:46