T
T
turchik28082020-02-10 19:58:46
C++ / C#
turchik2808, 2020-02-10 19:58:46

How to search for anagrams in a given dictionary?

Hello, give me an idea how to implement the search for anagrams in a given dictionary (at least visually, how it might look). I just don’t quite understand the principle of searching from a dictionary, it’s more or less clear from the text.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sumor, 2020-02-10
@Sumor

A simple idea for the Russian language.
Build the following index for the dictionary: Assign each letter
(except E=E) a number: A=0 B=1 ... Z= 31 In this case, UInt32 (unsigned int) is enough for the Russian language. ABAK = 1000000011 To search for an anagram, make up the same number and select applicants from the dictionary. Then the applicants are finally selected by the exact match of the occurring letters.

A
Andrey Vlasov, 2020-02-10
@andreyvlv

To search for anagrams consisting of the same number of letters or fewer letters, I did this:
In order for a word from the dictionary to be considered an anagram of our word, three conditions must match:
1. The number of letters in the dictionary word should not exceed the number of letters in our word (simple check for word length).
2. Also, the word in the dictionary should not contain letters that are not in our word. For example - the word "drill" is not an anagram of the word "robot".
3. The number of identical letters in the dictionary word should not exceed their number in the search word. This item was checked by compiling and comparing two associative arrays of the form: "letter" -> "number of its repetitions". For example: "tare" - [t] -> 1, [a] -> 2,
When these three conditions match, the word can be considered an anagram.
Here is the working code: https://tinyurl.com/rskes9g

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question