1. ## Equidistant Letter Sequencing

I am interested in performing Equidistant Letter Sequencing (as in the Bible Code) on various pieces of ASCII text. What would be the easiest way to do this? Searching for a string within a string is simple enough using the find(), but how would I go about seperating one string by integrals of each skip (i.e. every 5 letters of text, every 10 letters, every 20 letters).

Also, how efficient will this be? What is the fastest most efficient method of doing this in a large body of text (several thousand characters).

Thanks.

2. You could do something like this:
Code:
`double step = (double)extraspaces/spaces;`
Then increment a double by step once per space printed, and while it's >= 1, print a space and -= 1.

3. I think I need to describe what ELS is a little better. First I would have a large string of text. Then I would have a user specify a skip variable. Then I would skip every number of letters indicated by the skip variable.

An example:

UNDERWARANTY

position = position + skip

position = position + 2

position = 0 + 2 = 2; U N

position = 2 + 2 = 4; D E

position = 4 + 2 = 6; R W

position = 6 + 2 = 8; A R

position = 8 + 2 = 10; A N

position = 10 + 2 = 12; T Y

As you can see there are two two new strings generated by a skip of 2. UDRAAT and NEWRNY when displayed in the grid the word new is formed. I want to be able to search for instances of user specified words like this.

Thanks.

4. The only way I can think to do this so far is like this:

recieve the text and set it as a string - MasterString

recieve the desired search word and set it as a string - SearchWord

recieve a specified skip value and set it as an integer - skip

then seperate the MasterString into smaller strings of the length of the specified skip - an aray of strings called RowStrings

then seperate the strings effectivily into columns by setting a new array of strings to match the corresponding letters (i.e. the first letters of each row to the spaces in the array)

then use find() and rfind() to look for each instance of the SearchWord in the columns forwards and backwards

Is this an efficient way of doing this? What class functions/algorithms would I need to use in order to do this?

Any help would be greatly appreciated.

Thanks.

5. Can you show an example with a skip of 3.

6. Here is one with a skip of four:

NOMANKNOWSMYNAME

NOMA
NKNO
WSMY
NAME

This shows ASK imbedded with a negetive skip of four (that is searching from the end forward for the search word).

Thanks.

7. Originally Posted by Dave_Sinkula
Thanks for the help.

Yes I have already read all of that. I know how it works mathematically. I need to know how I might do the searching and seperating efficiently in C++.

Thanks.

8. Here is a specific question that I need an answer for in order to implement this first algorithm:

Is there a preset way to set part of a string array to another string array?

Thanks.

9. Could I use the string copy function in order to split up the master string into smaller intervals of the skip?

Thanks.

10. >> Is there a preset way to set part of a string array to another string array?
There is, but I can't think of a way to take advantage of it to get every nth element out of the string and into another.

I would think you could do this with a simple loop and a vector of strings whose size is equal to the skip value.

Pseudo-algorithm:

Get value for MASTERSTRING, SEARCHSTRING, and SKIP.

Create a vector of SKIP empty strings called SUBSTRINGLIST.
For each character in MASTERSTRING (call it MASTERSTRING[i])
-- Let j = i % SKIP
-- If SEARCHSTRING[SUBSTRINGLIST[j].size()] == MASTERSTRING[i] Then
-- -- SUBSTRINGLIST[j].push_back(MASTERSTRING[i])
-- -- If SUBSTRINGLIST[j].size() == SEARCHSTRING.size() Then SUCCESS!
-- Else
-- -- SUBSTRINGLIST[j].clear()
-- End If
End For

That algorithm is actually not quite right... If a substring is "xyzlllamasabc" and the search string is "llamas" it will fail because the third 'l' will cause the substring to clear and it will miss the word. I'll leave it to you to figure out how to fix that if you decide to use this basic algorithm.

11. Thanks alot for that. I am going to write some code now based on the ideas I collected here and I'll post what I have been able to do.

Thanks.

12. Here is what I have so far. I am not extremely familiar with vectors and I think I may have interpreted your algorithm incorrectly. I am getting an error after I input the variables. The program abrubtly ends. Take a look:

Code:
```#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main(int argc, char *argv[])
{
string TEXT = "";
string SEARCHWORD = "";
int SKIP = 0;

cout<<"Input text to search: "<<endl;
cin>>TEXT;
cout<<endl;

cout<<"Input word to search for: "<<endl;
cin>>SEARCHWORD;
cout<<endl;

cout<<"Input skip value: "<<endl;
cin>>SKIP;
cout<<endl;

vector<string> SUBSTRINGLIST(SKIP);

for(int i = 0; i <= TEXT.size(); i++)
{
for(int SUBSTRING = 0; SUBSTRING <= SUBSTRINGLIST.size(); SUBSTRING++)
{
if(SEARCHWORD[SUBSTRING] == TEXT[i])
{
SUBSTRINGLIST[SUBSTRING].push_back(TEXT[i]);
if(SUBSTRINGLIST[SUBSTRING].size() == SEARCHWORD.size())
{
cout<<"Search word found."<<endl;
}
else
{
SUBSTRINGLIST[SUBSTRING].clear();
}
}

}
}

system("PAUSE");
return EXIT_SUCCESS;
}```

Any help is appreciated.

Thanks.

13. I replaced SUBSTRINGLIST[SUBSTRING].clear() with just SUBSTRINGLIST.clear()

It fixed the abrupt exit, but I don't think the code is working. Have I coded this algorithm correctly?

Thanks.

14. I inputed my first example. It didn't find it. Am I doing something wrong here?

Thanks.