Let us disobey Bard's warning:
"Neither a borrower nor a lender be" and proceed as follows:
There are 2 lists, each of 10 words, one is the Borrower's list,
the other the Lender's list.
Borrower's list
1. chance
2. coma
3. ports
4. drive
5. change
6. people
7. vegas
8. train
9. stay
10.pardon
Lender's list:
1. orator
2. older
3. frigid
4. sport
5. melody
6. tube
7. toxin
8. grid
9. magic
10.jurist
For each of the 10 words in Borrower's list (e.g. coma):
- match a word of the same length from Lender's list, (in our example tube), such that by picking 2 letters from it (u & b) and inserting them in the same positions (2 & 3) in the 1st word selected by you a new valid word will be created.
It should denote either a color or geopolitical entity (Cuba in our case.).
Our example's solution can be thertefore coma; tube (2,3)==>Cuba
List 9 more pairs.
Hint: If solving manually - start with the short words.
chance to france from frigid
coma to cuba from tube
ports to paris from magic
drive to olive from older
change to orange from orator
people to purple from jurist
vegas to texas from toxin
train to spain from sport
stay to gray from grid
pardon to maroon from melody
The program below allows the user to put a word from the borrower's list into the text box called Text2. It then, when the user presses the command button, lists all the "words" possibly formed from the lender's list (stored on file lender.txt, and then on an internal array). This is a short enough list of possibilities so the user can scan it to find a city, country or color in text box Text1.
DefDbl A-Z
Dim lender$(10)
Private Sub Command1_Click()
Text1.Text = ""
For i = 1 To 10
If Len(lender(i)) = Len(Text2.Text) Then
w0$ = Text2.Text
For j = 1 To Len(w0) - 1
For k = j + 1 To Len(w0)
w1$ = w0
Mid(w1, j, 1) = Mid(lender(i), j, 1)
Mid(w1, k, 1) = Mid(lender(i), k, 1)
Text1.Text = Text1.Text & w0 & " to " & w1 & " from " & lender(i) & vbCrLf
DoEvents
Next
Next
End If
Next
End Sub
Private Sub Form_Load()
Form1.Visible = True
Text1.Text = ""
Open "lender.txt" For Input As #1
For i = 1 To 10
Input #1, lender(i)
Next
Close
End Sub
|
Posted by Charlie
on 2020-09-06 11:29:06 |