8

check the possible English words in a long random string (C ++)

 3 years ago
source link: https://www.codesd.com/item/check-the-possible-english-words-in-a-long-random-string-c.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

check the possible English words in a long random string (C ++)

advertisements

Given a random string:

KUHPVIBQKVOSHWHXBPOFUXHRPVLLDDAPPLEWPREDDVVIDWQRBHBGLLBBPKQUNRVOHQEIRLWOKKRDD

How do i check if the random string contains possible english words in it?

What's the most efficient way of searching for all possible English words embedded in this string?

I already downloaded english dictionary text file.

I would like to compare the string and english dictionary text file to find the possible words.

Can anyone give some hints how to do for this?


I recommend the brute force approach. After getting this method working, you can optimize later.

The brute force algorithm:

For each word in the dictionary,
  search the string for that word.

Other methods may take longer. You will have to ask yourself, "is spending time making this algorithm more efficient worthwhile?"

For infrequent uses, the answer would be no. As an answer to an Online Judge, maybe you will need to improve the efficiency. If you have a lot of strings like this, then maybe you should optimize the algorithm.

Tags dictionary

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK