Ten nine-letter words have been separated into units of three letters. The units have been randomly put in the below list. Can you determine the original 10 words?
dst rbr ard man tor rbo
ove and con erf ent dli
new fly spa dif hai ght
per all fis ban ush hea
dra gon fer wat duc her
bandstand, conductor, different, dragonfly, fisherman, hairbrush, headlight, newspaper, overboard, waterfall.
There are actually eleven possible words: "permanent" is the odd man out, since its inclusion would eliminate "newspaper", "fisherman" and "different".
The following Visual Basic program cannot be called "brute force", when it ran in a mere 10 seconds to load and scan my exhaustive 141,116 word database, which contains all the words considered valid in Scrabble (from "a" to "zyzzyvas") and even the names of all the major cities of Afghanistan (!!). (Not bad for somebody who has written fewer than 20 programs, if I do say so myself).
Imports System
Imports System.IO
Imports System.Text
Imports System.Runtime.InteropServices
Imports System.Math
Module Module1
Sub Main()
Randomize()
Dim strstarttime As String
Dim strendtime As String
Dim strend As String
Dim intloop1 As Integer = 199999
Dim intloop2 As Integer = 29
Dim strsylbs(30) As String
Dim strwords(200000) As String
strstarttime = TimeOfDay
Console.WriteLine( _
TimeOfDay & ": Start of execution.")
readfileintotable(intloop1, intloop2, strwords)
strsylbs(0) = "dst"
strsylbs(1) = "rbr"
strsylbs(2) = "ard"
strsylbs(3) = "man"
strsylbs(4) = "tor"
strsylbs(5) = "rbo"
strsylbs(6) = "ove"
strsylbs(7) = "and"
strsylbs(8) = "con"
strsylbs(9) = "erf"
strsylbs(10) = "ent"
strsylbs(11) = "dli"
strsylbs(12) = "new"
strsylbs(13) = "fly"
strsylbs(14) = "spa"
strsylbs(15) = "dif"
strsylbs(16) = "hai"
strsylbs(17) = "ght"
strsylbs(18) = "per"
strsylbs(19) = "all"
strsylbs(20) = "fis"
strsylbs(21) = "ban"
strsylbs(22) = "ush"
strsylbs(23) = "hea"
strsylbs(24) = "dra"
strsylbs(25) = "gon"
strsylbs(26) = "fer"
strsylbs(27) = "wat"
strsylbs(28) = "duc"
strsylbs(29) = "her"
intloop1 = intloop2
Console.WriteLine( _
": Loop limit reset to " & Str(intloop1))
strendtime = TimeOfDay
findthewords(strwords, strsylbs, intloop1)
Console.WriteLine(" ")
Console.WriteLine("Start of execution: " & strstarttime)
strendtime = TimeOfDay
Console.WriteLine( _
TimeOfDay & ": End of execution.")
strend = "?"
Console.WriteLine(" ")
While strend <> "x"
Console.WriteLine( _
"Please enter X to exit program.")
strend = LCase(Console.ReadLine())
End While
End Sub
Sub readfileintotable(ByRef intloop1, ByRef intloop2, _
ByRef strwords)
Dim intsub1 As Integer
Dim strline As String
Dim strerrorflag As String
Dim intreccount As Integer
Dim objStreamReader As StreamReader
For index1 As Integer = 0 To intloop1
strwords(index1) = " "
Next
intreccount = 0
intsub1 = 0
intreccount = 0
Console.WriteLine( _
TimeOfDay & ": Reading the sorted wordlist file...")
strline = " "
objStreamReader = _
New StreamReader("C:VBWORDLIST.MASTER")
strerrorflag = "n"
Do While Not strline Is Nothing
strline = objStreamReader.ReadLine
If strline <= " " Then
Exit Do
End If
If intsub1 <= intloop1 Then
putintable(strline, intloop1, intloop2, _
intsub1, strwords, intreccount)
Else
strerrorflag = "y"
End If
Loop
objStreamReader.Close()
If strerrorflag = "n" Then
Console.WriteLine( _
TimeOfDay & ": Done. " & Str(intreccount) & _
" records read.")
Else
Console.WriteLine(TimeOfDay & _
": ERROR !!!! Please increase table sizes " & _
"to " & Str(intreccount))
Console.ReadLine()
End
End If
End Sub
Sub putintable(ByRef strline, ByRef intloop1, _
ByRef intloop2, ByRef intsub1, ByRef strwords, _
ByRef intreccount)
Dim strwork(100) As String
Dim strstring As String
Dim intsub2 As Integer
Dim intlettercount As Integer
intsub2 = 0
For index1 As Integer = 0 To 99
strwork(index1) = " "
Next
strstring = LCase(strline)
strline = strstring
For index1 As Integer = 1 To Len(strline)
If (Mid(strline, index1, 1) >= "a" And _
Mid(strline, index1, 1) <= "z") Then
intlettercount += 1
strwork(intsub2) = Mid(strline, index1, 1)
intsub2 += 1
End If
Next
strline = ""
For index1 As Integer = 0 To 99
If strwork(index1) = " " Then
Exit For
End If
strline &= strwork(index1)
Next
strwords(intsub1) = strline
intloop2 = intsub1
intsub1 += 1
intreccount += 1
End Sub
Sub findthewords(ByRef strwords, ByRef strsylbs, _
ByRef intloop1)
Dim strwork(9) As String
Dim str1st As String
Dim str2nd As String
Dim str3rd As String
Dim strline As String
Dim strhit As String
For index1 As Integer = 0 To intloop1
If Len(strwords(index1)) = 9 Then
strline = strwords(index1)
For index2 As Integer = 1 To Len(strline)
strwork(index2 - 1) = Mid(strline, index2, 1)
Next
str1st = ""
str2nd = ""
str3rd = ""
For index3 As Integer = 0 To 2
str1st &= strwork(index3)
Next
For index4 As Integer = 3 To 5
str2nd &= strwork(index4)
Next
For index5 As Integer = 6 To 8
str3rd &= strwork(index5)
Next
For index6 As Integer = 0 To 29
If strsylbs(index6) = str1st Then
For index7 As Integer = 0 To 29
If strsylbs(index7) = str2nd Then
For index8 As Integer = 0 To 29
If strsylbs(index8) = str3rd Then
Console.WriteLine(strline)
End If
Next
End If
Next
End If
Next
End If
Next
End Sub
End Module
Edited on August 10, 2004, 1:33 pm
|
Posted by Penny
on 2004-08-10 11:42:10 |