开发者

Random word from giving letter

开发者 https://www.devze.com 2022-12-23 09:02 出处:网络
Is there any possible 开发者_运维知识库code for getting output in php(all possible word from word dictionary)

Is there any possible 开发者_运维知识库code for getting output in php(all possible word from word dictionary)

for example....for word "werflo"

  1. flower

  2. fowler

  3. reflow

  4. wolfer


  1. Take your word list, order each word's letters (alphebetical or otherwise, as long as it's consistent).
  2. Associate each word with its ordered letter string
  3. Apply the same letter ordering to your input
  4. Find the matching words, which is now trivial as you just need to find those where the ordered letter sequence matches.


I don't know PHP, but you could

  1. pre-sort all the words in the dictionary, remembering their original position (for example, "flower" will be stored as "eflorw"); sort the dictionary lexocographically;
  2. sort the letters in your input word the same way;
  3. with binary search find the sorted word within the sorted dictionary;
  4. by the stored index, find the original words in the original dictionary.
0

精彩评论

暂无评论...
验证码 换一张
取 消