Dana DeLouis
12/15/2006 7:07:00 AM
> ...and suggest performance tweaks that'd be great.
Hi. Don't know if this idea would be any faster.
How about the first loop being 1 to 5, since we know we must have at least
one Vowel (v).
Hard code all 24 permutations so that we can sequence in our vowel.
Again, don't know if this general outline is faster though.
For p = 1 To 5
v = Choose(p, "a", "e", "i", "o", "u")
For i = 65 To 88
For j = i + 1 To 89
For k = j + 1 To 90
'Test all 24 Permutations here
'1 {v, i, j, k}
'2 {v, i, k, j}
'3...etc
'24 {k, j, i, v}
--
HTH :>)
Dana DeLouis
Windows XP & Office 2003
"Nick" <nickcarda@gmail.com> wrote in message
news:1166137422.579447.261340@16g2000cwy.googlegroups.com...
> Hi guys, I've written some code that finds four letter words that don't
> have repeating letters (ex: Foot wouldn't count, two O's) The problem
> is that it takes a long time to generate them all. Below is my code, if
> anyone wants to take a look at it and suggest performance tweaks that'd
> be great. If you have a different method/approach to getting the list
> of 4 letter words that might be faster I'd like to hear that too.
>
> Sub TotalRebuild()
> GoodToGo = MsgBox("This will rebuild the whole wordlist, and it takes a
> Long time, over 10 minutes. Are you sure?", vbOKCancel, "Warning, this
> takes forever")
>
> If GoodToGo = vbCancel Then End
>
> Application.ScreenUpdating = False
> 'Application.WindowState = xlMinimized
> 'Application.Visible = False
>
> Range("A:A").ClearContents 'clear column A so we can put the words in
>
> For One = 65 To 90 'Set up loop for the first letter
> o = Chr(One) ' variable o holds first letter
>
> For Two = 65 To 90 'set up loop for second letter
> t = Chr(Two) ' variable t holds second letter
>
> For Three = 65 To 90 'set up loop for third letter
> r = Chr(Three) 'variable r holds third letter
>
> For Four = 65 To 90 'set up loop for fourth letter
> f = Chr(Four) 'variable f holds fourth letter
> dupe = 0 'reset duplicate variable
> If o = t Then dupe = 1 ' if letters repeat, then
> dupe = 1
> If o = r Then dupe = 1
> If o = f Then dupe = 1
> If t = r Then dupe = 1
> If t = f Then dupe = 1
> If r = f Then dupe = 1
>
> If dupe = 0 Then ' if no leters repeat, then put
> the letters together
> word = o & t & r & f
>
> If Application.CheckSpelling(word) = True Then
> ' spellcheck the word
> rw = rw + 1 'increment what row we put the
> word in
> Cells(rw, 1) = word 'put the word in the
> row rw, column 1
> End If
>
> End If
>
> Next Four
>
> Next Three
>
> Next Two
>
> Next One
>
> 'Application.Visible = True
> 'Application.WindowState = xlMaximized
> Application.ScreenUpdating = True
>
> MsgBox "Done"
>
> End Sub
>