Answer the question
In order to leave comments, you need to log in
How to make a selection of words from a dictionary to get a given phrase (anagrams)?
I want to make a service similar to this:
www.wordplays.com/anagrammer
The bottom line is this: the user enters a certain phrase. In response, he receives sentences from words, the letters of which are all present in the original phrase. The words are taken from the database.
I came to the conclusion that each word must be assigned a key, which is all the characters of the word ordered alphabetically. For example, the word "button". The keyword for this word will be "bnootu".
The algorithm boils down to the following:
Answer the question
In order to leave comments, you need to log in
The multidimensional knapsack problem.
Let's say we have the phrase "aaabbc" and a dictionary
aab
abb
abc
bbcc
aac
1000 0000
0000 0000
0000 0000
1000 0000
0010 0000
0000 0000
abb=(1,2,0)
1000 0000
0010 0000
0100 0000
abc=(1,1,1)
1000 0000
0010 0100
0100 0001
aac=(2,0,1)
1000 0010
0010 0100
0100 0001
aab
abb
aab
abb
abc
bbcc
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question