There are 25 distinct letters in the grid below.
Try to create the longest word starting by any letter and moving only to the neighboring square (horizontally, vertically or diagonally) without repeating a letter.
A M W Y F
C K E H J
I P B L D
V N G U R
Z X S T O
All words are acceptable as long as they appear in a reliable dictionary
Sorting the output of
DefDbl A-Z
Dim crlf$, r, c, psn, w$, grid$(6, 6), good, used(6, 6)
Private Sub Form_Load()
Text1.Text = ""
crlf$ = Chr(13) + Chr(10)
Form1.Visible = True
DoEvents
For r = 1 To 5
For c = 1 To 5
psn = psn + 1
grid$(r, c) = Mid("amwyfckehjipbldvngurzxsto", psn, 1)
Next
Next
Open "c:\words\words.txt" For Input As #1
Do
Line Input #1, w$
w = LTrim(RTrim(w))
If Len(w) > 2 Then
good = 0
For r0 = 1 To 5
For c0 = 1 To 5
If grid(r0, c0) = Left(w, 1) Then
For i = 1 To 5
For j = 1 To 5
used(i, j) = 0
Next
Next
psn = 1
r = r0: c = c0
used(r, c) = 1
addOn
End If
Next
Next
If good Then
Text1.Text = Text1.Text & mform(Len(w), "##") & " " & w & crlf
If Len(w) > mx Then mx = Len(w)
End If
End If
DoEvents
Loop Until EOF(1)
Close 1
Text1.Text = Text1.Text & mx & " done"
End Sub
Sub addOn()
DoEvents
For dr = -1 To 1
For dc = -1 To 1
If dr <> 0 Or dc <> 0 Then
newr = r + dr: newc = c + dc
If used(newr, newc) = 0 Then
If grid(newr, newc) = Mid(w, psn + 1, 1) Then
psn = psn + 1
r = newr: c = newc
used(r, c) = 1
If psn = Len(w) Then
good = 1
Else
addOn
End If
used(r, c) = 0
r = r - dr: c = c - dc
psn = psn - 1
End If
End If
End If
Next
Next
End Sub
Function mform$(x, t$)
a$ = Format$(x, t$)
If Len(a$) < Len(t$) Then a$ = Space$(Len(t$) - Len(a$)) & a$
mform$ = a$
End Function
gives the following list of formable words of at least 3 letters:
3 bel
3 bey
3 bud
3 bug
3 bur
3 bus
3 but
3 cam
3 dub
3 dug
3 duo
3 eld
3 gul
3 gut
3 hem
3 hep
3 hew
3 hey
3 ick
3 ins
3 kep
3 key
3 kin
3 kip
3 lek
3 ley
3 lug
3 mac
3 mel
3 mew
3 nip
3 ort
3 oud
3 our
3 out
3 peh
3 pew
3 pic
3 pin
3 rot
3 rub
3 rug
3 rut
3 sub
3 tor
3 tub
3 tug
3 urd
3 uts
3 web
3 why
3 wye
3 yeh
3 yep
3 yew
4 acme
4 akin
4 bema
4 blew
4 blur
4 bugs
4 burd
4 burl
4 bust
4 buts
4 cake
4 came
4 drub
4 drug
4 dugs
4 duro
4 dust
4 epic
4 gley
4 glut
4 gust
4 guts
4 held
4 kame
4 kepi
4 king
4 kins
4 lube
4 lugs
4 lust
4 mack
4 make
4 meld
4 nick
4 orle
4 orts
4 oust
4 outs
4 pica
4 pick
4 pika
4 pike
4 ping
4 pins
4 rots
4 rout
4 rube
4 rugs
4 rule
4 rust
4 ruts
4 snip
4 stub
4 stud
4 surd
4 tour
4 trug
4 tube
4 tugs
4 tule
4 turd
4 weka
4 weld
4 whey
4 yeld
5 acing
5 blurt
5 bugle
5 cakey
5 camel
5 drugs
5 eking
5 gluts
5 gusto
5 ingle
5 kings
5 pekin
5 pings
5 roust
5 routs
5 ruble
5 snick
5 snipe
5 stour
5 torus
5 trugs
5 ulema
6 blurts
6 burley
6 caking
6 macing
6 making
6 nickel
6 pekins
6 rouble
6 stroud
7 makings
7 trouble
13 troublemaking
14 troublemakings
the largest of which is the 14-letter "troublemakings".
|
Posted by Charlie
on 2019-08-08 10:31:11 |