One interesting means of constructing a word search matrix is to take some written text (in upper case), strip out all but the characters A - Z, and format the resulting sequence of characters into columns of s characters. That is, taking s = 9 and given the text
Our revels now are ended. These our actors,
As I foretold you, were all spirits and
Are melted into air, into thin air:
And, like the baseless fabric of this vision,
The cloud-capp'd towers, the gorgeous palaces,
The solemn temples, the great globe itself,
Ye all which it inherit, shall dissolve
And, like this insubstantial pageant faded,
Leave not a rack behind. We are such stuff
As dreams are made on, and our little life
Is rounded with a sleep.
We obtain the following word-search matrix:
ONERIYLNEIITSFODEGCESGLHEDNSNAEAWSEDRFEE UODAFOSDDNRHSTNCREEMTLFIRIDITNACETAELEDE RWTCOUPAITAEFHTASOSNHOYCISLNITVKAUMOIIWP RAHTRWIRNONBAIHPTUTTEBEHTSISAFEBRFSNTSI EREOEERETTDABSEPHSHEGEAISOKULANEEFAATRT VESRTRIMOHLSRVCDEPEMRIATHLEBPDOHSARNLOH EEESOETEAIIEIILTGASPETLIAVTSAETIUSEDEUA LNOALASLINKLCSOOOLOLASLNLEHTGDANCDMOLNS SDUSDLATRAEEOIUWRALETEWHLAIAELRDHRAUIDL
We can now search this matrix for words. For example, the word "SAFE" can be found starting at lexicographic position 246 and running eastward in the text. 3 Since, running row-wise, we are looking at every s'th character, the value of s is sometimes called a skip value.
For this problem, you will be given search words, a search text, and a skip value. Your job (well, really, your program's job) is to find the location of each of the search words within the search text, formatted into a search matrix according to the given skip value.
NOT FOUND
3 By lexicographic position we mean the numerical position with the search matrix when counting consecutively and column-wise from the first character, which is position 0.
4 The number of lines in Hamlet.
9 5 SAFE TOES SHAKE SPEARE GLOBE 11 OUR REVELS NOW ARE ENDED. THESE OUR ACTORS, AS I FORETOLD YOU, WERE ALL SPIRITS, AND ARE MELTED INTO AIR, INTO THIN AIR: AND, LIKE THE BASELESS FABRIC OF THIS VISION, THE CLOUD-CAPP'D TOWERS, THE GORGEOUS PALACES, THE SOLEMN TEMPLES, THE GREAT GLOBE ITSELF, YEA, ALL WHICH IT INHERIT, SHALL DISSOLVE, AND, LIKE THIS INSUBSTANTIAL PAGEANT FADED, LEAVE NOT A RACK BEHIND. WE ARE SUCH STUFF AS DREAMS ARE MADE ON; AND OUR LITTLE LIFE IS ROUNDED WITH A SLEEP.
SAFE 246 E TOES 85 SW SHAKE NOT FOUND SPEARE NOT FOUND GLOBE 189 S