Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > General > Dis-Assemble


Reply
 
Thread Tools Display Modes
  #1  
Old 10-06-2006, 08:31 PM
Mystery Mystery is offline
Junior Contributor
 
Join Date: Sep 2005
Posts: 228
Default Dis-Assemble


I want to take a base word, and dis-assemble it into all the possiblities.

For example, i wanna take the word mike, and make these combos:

mike
mik
mke
mie
me
mi
mk
ik
ie
ke

Its basically removing a letter, and making combos for the letters there.. Does that make sense?
Reply With Quote
  #2  
Old 10-06-2006, 09:55 PM
Cerian Knight's Avatar
Cerian Knight Cerian Knight is offline
Multi-Technologist

Super Moderator
* Expert *
 
Join Date: May 2004
Location: Michigan
Posts: 3,740
Default

This is not exactly what you want, but it should give you some ideas. Just add two textboxes to a form, making the second one multiline:
Code:
Private Sub Text1_KeyPress(KeyAscii As Integer) Dim I As Long Dim L As Long Dim N As String Dim OS As String Dim NA() As Boolean Dim NB() As String If KeyAscii = 13 Then N = Text1.Text L = Len(N) If L Then ReDim NA(L) ReDim NB(L) For I = 1 To L NB(I) = Mid(N, I, 1) Next Do OS = "" For I = 1 To L If NA(I) = False Then OS = OS & NB(I) Next For I = L To 1 Step -1 NA(I) = NA(I) + 1 If NA(I) = True Then Exit For Next If Len(OS) Then Text2.SelText = OS & vbCrLf Loop While Len(OS) End If End If End Sub
Reply With Quote
  #3  
Old 10-06-2006, 09:57 PM
passel's Avatar
passel passel is offline
Sinecure Expert

Super Moderator
* Guru *
 
Join Date: Jun 2003
Location: Upstate New York, usa
Posts: 7,714
Default

Since you should do your own homework, hopefully the above is not too close to what you want.
Of course, the instructor might want you to explain it, so if you can do that, maybe you'll have learned something to make it worth it.
__________________
There Is An Island Of Opportunity In The Middle of Every Difficulty.
Miss That, Though, And You're Pretty Much Doomed.
Reply With Quote
  #4  
Old 10-06-2006, 10:09 PM
Mystery Mystery is offline
Junior Contributor
 
Join Date: Sep 2005
Posts: 228
Default

my homework? its a personal project im working on. im working on a program that uses a dictionary reference, and takes a bunch of letters, and dis-assembles them, then checks each combination of the letters for a word match.

but thanks passel for thinking its homework!
Reply With Quote
  #5  
Old 10-07-2006, 12:21 AM
passel's Avatar
passel passel is offline
Sinecure Expert

Super Moderator
* Guru *
 
Join Date: Jun 2003
Location: Upstate New York, usa
Posts: 7,714
Default

Well, based on your example, it doesn't look like it does all combinations.
You want it to give you ike, but not kie, or eik, etc., so you want the characters in their original order, but they don't have to be contiguous, so you're not looking for subwords in existing words.
Those two cases, matching subwords, or finding all combinations or permutations I could see some applications for.

Choosing all groups of letters in the same order but not necessarily contiguous is an ideal recursion programming problem, so looks just like an exercise you would get in a class on recursive programming.
Attached Images
File Type: jpg Recursion.jpg (12.1 KB, 13 views)
__________________
There Is An Island Of Opportunity In The Middle of Every Difficulty.
Miss That, Though, And You're Pretty Much Doomed.

Last edited by passel; 10-07-2006 at 01:27 AM.
Reply With Quote
  #6  
Old 10-07-2006, 02:07 PM
Mystery Mystery is offline
Junior Contributor
 
Join Date: Sep 2005
Posts: 228
Default

I have a great permutation example, does all possible combos, but it generates way too many. I dont want my program to take an hour searching 20,000 possible comboinations for words in the dictionary.
Reply With Quote
  #7  
Old 10-08-2006, 01:18 AM
passel's Avatar
passel passel is offline
Sinecure Expert

Super Moderator
* Guru *
 
Join Date: Jun 2003
Location: Upstate New York, usa
Posts: 7,714
Default

Well, as I said, it looks like a good job for a recursive routine.
I haven't done a lot of recursive routines, so don't know if this is the best approach, but I would write a routine that accepts a string and a number. The string will represent the string at the current stage level of recursion, and the number will represent what character index the caller is working on.
The routine will just loop from the next character (the character passed in + 1) through the number of characters. It will append the character to the original string passed in and print it (or save it, or whatever you want to do).
It would then call itself passing the string in its current state (with the appended character) and the character index (the value of the loop counter)

The recursion allows all the combinations to be created with a minimum amount of code (about six lines of code).

If you call the recursive routine passing a null string and 0, then all combinations meeting your criteria, will be created, including single letter words.
Assuming you don't want single letter words, you could either add a simple test in the recursion routine to not print single letter words, or you could call the recursive routine in a loop, passing each of the single characters of the string and the index of that character. Since you don't print the single character in your loop, the recursive routine will be appending characters to that orignal one character string you passed in, so will print 2,3,4 etc character length strings.
That routine would also print the full string, so you would add a check in the recursive routine to not print the word if its length was the same as the original word, assuming you don't want the original word as part of your list.
__________________
There Is An Island Of Opportunity In The Middle of Every Difficulty.
Miss That, Though, And You're Pretty Much Doomed.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->