Given 4 common English words:
RESTORATION
SUMMERTIME
UMBILICALand
CATERING.
Chose 2 successive letters from the 1st word, then 2 successive letters from the 2nd word, then 3rd and the 4th to create a valid English non-esoteric
word of 8 letters.
"St er li ng" is a good example.
Find additional word(s) complying with the above process.
Additional words are REMEMBER, RETILING and TIMELIER.
Output list:
remember
retiling
remember
sterling
timelier
timelier
Duplicated words stem from "me" occurring twice in "summertime".
from:
DefDbl A-Z
Dim crlf$
Private Sub Form_Load()
Form1.Visible = True
Text1.Text = ""
crlf = Chr$(13) + Chr$(10)
a$ = "restoration"
b$ = "summertime"
c$ = "umbilical"
d$ = "catering"
For apos = 1 To Len(a) - 1
For bpos = 1 To Len(b) - 1
For cpos = 1 To Len(c) - 1
For dpos = 1 To Len(d) - 1
w$ = Mid(a, apos, 2) + Mid(b, bpos, 2) + Mid(c, cpos, 2) + Mid(d, dpos, 2)
If isWord(w) Then
Text1.Text = Text1.Text & w & crlf
End If
DoEvents
Next
Next
Next
Next
Text1.Text = Text1.Text & crlf & " done"
End Sub
Function isWord(w$)
n = Len(w$)
w1$ = Space$(n)
Open "c:\words\words" + LTrim$(Str$(n)) + ".txt" For Binary As #2
l = LOF(2) / n
low = 1: high = l
Do
middle = Int((low + high) / 2)
Get #2, (middle - 1) * n + 1, w1$
If w1$ = w$ Then isWord = 1: Close 2: Exit Function
If w1$ < w$ Then low = middle + 1 Else high = middle - 1
Loop Until low > high
isWord = 0
Close 2
End Function
|
Posted by Charlie
on 2017-07-04 13:37:01 |