ArtsAutosBooksBusinessEducationEntertainmentFamilyFashionFoodGamesGenderHealthHolidaysHomeHubPagesPersonal FinancePetsPoliticsReligionSportsTechnologyTravel

Porgramme to Solve the words in a set of jumbled Alphabets

Updated on May 3, 2012

programme to get valid words from jumbled letters

I had created this program while playing text games on BING so that I can quickly solve puzzles and earn points... lost the lust after sometime. But searched a lot on Internet at that time and did not find it. I found that hub users may be interested....

take it into word VBA macro and run "my trained script"

provide the jumbled letters from Bing text game...

It would generate all valid combinations for 3,4, 5, 6 and 7 letter words and write on the page. solve your text puzzles fast... Did not get time to clean.. but it works.. the more letter you give and more time it takes... try up to 7 letters.. it takes about 30 - 50 seconds.



Recursive program for generating all words for given letters

Public myWords() As String
Public wordCount As Integer
Public xx As Long
Public expString As Words
Public scrambDict As New Scripting.Dictionary
Public Sub myTrainedScript()

Dim word As String
Dim strcombis As String
Dim l, pos, c
Dim myStrs() As String * 1
Dim wordLen As Integer
Dim mlen, posx
Dim loopWord
xx = 0

wordCount = 0
ReDim myWords(wordCount) As String

word = InputBox("Please give me letters", "Ask Letters")
word = sortStr(word)
wordLen = Len(word)
ReDim myStrs(wordLen) As String * 1

For l = 1 To wordLen
  myStrs(l) = Mid(word, l, 1)
strCombi word
elimOnePos word, 3

Debug.Print xx

wordCount = UBound(myWords)

If wordCount = 0 Then Exit Sub

For i = 1 To wordCount
  For j = i + 1 To wordCount
  If myWords(i) > myWords(j) Then
    temp = myWords(i)
    myWords(i) = myWords(j)
    myWords(j) = temp
  End If

For i = 1 To wordCount
  For j = i + 1 To wordCount
    If Len(myWords(i)) > Len(myWords(j)) Then
      temp = myWords(i)
      myWords(i) = myWords(j)
      myWords(j) = temp
    End If

mylen = Len(myWords(1))

For i = 1 To wordCount
  If myWords(i) <> myWords(i - 1) Then
  If Len(myWords(i)) = mylen Then
    ActiveDocument.Range.InsertAfter myWords(i) & ", "
  ActiveDocument.Range.InsertAfter Chr(13)
  ActiveDocument.Range.InsertAfter myWords(i) & ", "
  mylen = Len(myWords(i))
 End If
End If
End Sub
Public Sub elimOnePos(srcStr, tgtLen)
Dim thisLen As Integer, thisLoopStr As String
thisLen = Len(srcStr)
For i = 1 To thisLen
 Select Case i
  Case 1
    thisLoopStr = Right(srcStr, thisLen - 1)
  Case thisLen
    thisLoopStr = Left(srcStr, thisLen - 1)
  Case Else
    thisLoopStr = Mid(srcStr, 1, i - 1) & Mid(srcStr, i + 1, thisLen - i)
  End Select
  thisLoopStr = sortStr(thisLoopStr)
  If Not (scrambDict.Exists(thisLoopStr)) Then
  scrambDict.Add thisLoopStr, thisLoopStr
  strCombi thisLoopStr
  If Len(thisLoopStr) <> tgtLen Then
  elimOnePos thisLoopStr, tgtLen
  End If
  End If
  xx = xx + 1
End Sub

Sub strCombi(inputString As String) ' main program structure begins here
Dim seedinput As String * 1
Dim remainstrX As String
Dim chkchar As String * 1
Dim stringLength As Integer, i As Integer
Dim strs() As String * 1
stringLength = Len(inputString)
ReDim strs(stringLength) As String * 1
inputString = sortStr(inputString)
seedinput = ""
For i = 1 To stringLength
  strs(i) = Mid(inputString, i, 1)
For i = 1 To stringLength
  If (strs(i) <> seedinput) Then
  seedinput = strs(i)
  Select Case i
  Case 1
  remainstrX = Right(inputString, stringLength - 1)
  Case stringLength
  remainstrX = Left(inputString, stringLength - 1)
  Case Else
  remainstrX = Mid(inputString, 1, i - 1) & Mid(inputString, i + 1, stringLength - i)
 End Select
  Call StrRecur(seedinput, Trim(remainstrX), 0, "@")
  End If
End Sub

Sub StrRecur(instrX, mainstrX, cplace, cchar) ' this is a recursive subsroutine
Dim chklen As Integer, i As Integer
Dim seedStr As String, nxtstr As String
Dim nxtchar
Dim strsX() As String * 1

chklen = Len(mainstrX)
If (chklen = 1) Then
  seedStr = instrX & mainstrX
  GoTo myt20
End If
nxtchar = ""
ReDim strsX(chklen) As String * 1
For i = 1 To chklen
  strsX(i) = Mid(mainstrX, i, 1)

For i = 1 To chklen
  If (nxtchar <> strsX(i)) Then
  nxtchar = strsX(i)
  seedStr = instrX & nxtchar
  Select Case i
  Case 1
  nxtstr = Mid(mainstrX, i + 1, chklen - i)
  Case chklen
  nxtstr = Mid(mainstrX, 1, i - 1)
  Case Else
  nxtstr = Mid(mainstrX, 1, i - 1) & Mid(mainstrX, i + 1, chklen - i)
 End Select
  Call StrRecur(Trim(seedStr), Trim(nxtstr), cplace, cchar)
  End If
GoTo myt30
myt20: If (cplace <> 0) Then
  If (Mid(seedStr, cplace1) = cchar) Then
  If Application.CheckSpelling(seedStr) Then
  ActiveDocument.Paragraphs.Add (seedStr)
  End If
End If
  If Application.CheckSpelling(seedStr) Then
  wordCount = wordCount + 1
  ReDim Preserve myWords(wordCount) As String
  myWords(wordCount) = seedStr
  End If
 End If
myt30: xxd = 0
End Sub

Function sortStr(instrX) As String
Dim temp As String * 1
Dim strLen As Integer
Dim strs() As String * 1

strLen = Len(instrX)
ReDim strs(strLen) As String * 1

For i = 1 To strLen
  strs(i) = Mid(instrX, i, 1)

For i = 1 To strLen - 1
  For j = (i + 1) To strLen
  If (strs(i) > strs(j)) Then
 temp = strs(i)
  strs(i) = strs(j)
  strs(j) = temp
  End If

sortStr = ""

For i = 1 To strLen
 sortStr = sortStr & strs(i)

End Function


    0 of 8192 characters used
    Post Comment

    • profile image


      8 years ago

      Hello There,

      it would be great if someone help with how to rap this into excel ?



    • HubChief profile imageAUTHOR

      hubchief - pen name 

      9 years ago from United States

      that is helpful. I can add a hub for how to use VBA and what are its uses if someone has not done that yet. Do you think If I made an EXE would help?

    • yamanote profile image


      9 years ago from UK/Spain

      i hadnt used the word VBA macro before, thanks


    This website uses cookies

    As a user in the EEA, your approval is needed on a few things. To provide a better website experience, uses cookies (and other similar technologies) and may collect, process, and share personal data. Please choose which areas of our service you consent to our doing so.

    For more information on managing or withdrawing consents and how we handle data, visit our Privacy Policy at:

    Show Details
    HubPages Device IDThis is used to identify particular browsers or devices when the access the service, and is used for security reasons.
    LoginThis is necessary to sign in to the HubPages Service.
    Google RecaptchaThis is used to prevent bots and spam. (Privacy Policy)
    AkismetThis is used to detect comment spam. (Privacy Policy)
    HubPages Google AnalyticsThis is used to provide data on traffic to our website, all personally identifyable data is anonymized. (Privacy Policy)
    HubPages Traffic PixelThis is used to collect data on traffic to articles and other pages on our site. Unless you are signed in to a HubPages account, all personally identifiable information is anonymized.
    Amazon Web ServicesThis is a cloud services platform that we used to host our service. (Privacy Policy)
    CloudflareThis is a cloud CDN service that we use to efficiently deliver files required for our service to operate such as javascript, cascading style sheets, images, and videos. (Privacy Policy)
    Google Hosted LibrariesJavascript software libraries such as jQuery are loaded at endpoints on the or domains, for performance and efficiency reasons. (Privacy Policy)
    Google Custom SearchThis is feature allows you to search the site. (Privacy Policy)
    Google MapsSome articles have Google Maps embedded in them. (Privacy Policy)
    Google ChartsThis is used to display charts and graphs on articles and the author center. (Privacy Policy)
    Google AdSense Host APIThis service allows you to sign up for or associate a Google AdSense account with HubPages, so that you can earn money from ads on your articles. No data is shared unless you engage with this feature. (Privacy Policy)
    Google YouTubeSome articles have YouTube videos embedded in them. (Privacy Policy)
    VimeoSome articles have Vimeo videos embedded in them. (Privacy Policy)
    PaypalThis is used for a registered author who enrolls in the HubPages Earnings program and requests to be paid via PayPal. No data is shared with Paypal unless you engage with this feature. (Privacy Policy)
    Facebook LoginYou can use this to streamline signing up for, or signing in to your Hubpages account. No data is shared with Facebook unless you engage with this feature. (Privacy Policy)
    MavenThis supports the Maven widget and search functionality. (Privacy Policy)
    Google AdSenseThis is an ad network. (Privacy Policy)
    Google DoubleClickGoogle provides ad serving technology and runs an ad network. (Privacy Policy)
    Index ExchangeThis is an ad network. (Privacy Policy)
    SovrnThis is an ad network. (Privacy Policy)
    Facebook AdsThis is an ad network. (Privacy Policy)
    Amazon Unified Ad MarketplaceThis is an ad network. (Privacy Policy)
    AppNexusThis is an ad network. (Privacy Policy)
    OpenxThis is an ad network. (Privacy Policy)
    Rubicon ProjectThis is an ad network. (Privacy Policy)
    TripleLiftThis is an ad network. (Privacy Policy)
    Say MediaWe partner with Say Media to deliver ad campaigns on our sites. (Privacy Policy)
    Remarketing PixelsWe may use remarketing pixels from advertising networks such as Google AdWords, Bing Ads, and Facebook in order to advertise the HubPages Service to people that have visited our sites.
    Conversion Tracking PixelsWe may use conversion tracking pixels from advertising networks such as Google AdWords, Bing Ads, and Facebook in order to identify when an advertisement has successfully resulted in the desired action, such as signing up for the HubPages Service or publishing an article on the HubPages Service.
    Author Google AnalyticsThis is used to provide traffic data and reports to the authors of articles on the HubPages Service. (Privacy Policy)
    ComscoreComScore is a media measurement and analytics company providing marketing data and analytics to enterprises, media and advertising agencies, and publishers. Non-consent will result in ComScore only processing obfuscated personal data. (Privacy Policy)
    Amazon Tracking PixelSome articles display amazon products as part of the Amazon Affiliate program, this pixel provides traffic statistics for those products (Privacy Policy)