PC Review


Reply
Thread Tools Rate Thread

Creating character combinations out of a possible set...

 
 
Shaka215@gmail.com
Guest
Posts: n/a
 
      5th Jan 2007
Hey! Here is the problem...I can't figure out how to make it so every
possible combination of a series of letters (A-Z) and Numbers (0-9) is
displayed I saw someones code to make it possible for three characters
but I am looking to do it with like 10 characters...The code I saw was
this...

Sub comboo()
Dim s(36) As String
For i = 0 To 9
s(i) = Chr(i + 48)
Next
For i = 10 To 36
s(i) = Chr(i + 55)
Next


k = 1
For i = 0 To 35
For j = 0 To 35
For l = 0 To 35
Cells(k, "A").Value = s(i) & s(j) & s(l)
k = k + 1
Next
Next
Next
End Sub

Any ideas? Any help is much appreciated!!

 
Reply With Quote
 
 
 
 
Bernard Liengme
Guest
Posts: n/a
 
      5th Jan 2007
With 26 letters and 10 digits you have 36 possible characters in each
position
So for 10 positions you will have 36^10 possible outcomes
This is about 4E+15 or a mere 1/1000 the age of the universe expressed in
seconds
Hope you have a fast CPU
And a big piece of paper on which to print the results
best wishes
--
Bernard V Liengme
www.stfx.ca/people/bliengme
remove caps from email

<(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hey! Here is the problem...I can't figure out how to make it so every
> possible combination of a series of letters (A-Z) and Numbers (0-9) is
> displayed I saw someones code to make it possible for three characters
> but I am looking to do it with like 10 characters...The code I saw was
> this...
>
> Sub comboo()
> Dim s(36) As String
> For i = 0 To 9
> s(i) = Chr(i + 48)
> Next
> For i = 10 To 36
> s(i) = Chr(i + 55)
> Next
>
>
> k = 1
> For i = 0 To 35
> For j = 0 To 35
> For l = 0 To 35
> Cells(k, "A").Value = s(i) & s(j) & s(l)
> k = k + 1
> Next
> Next
> Next
> End Sub
>
> Any ideas? Any help is much appreciated!!
>



 
Reply With Quote
 
Ken Johnson
Guest
Posts: n/a
 
      5th Jan 2007


Where are you intending to display them?

There are 36^10 of them, which is more than three million,six hundred
and fifty-six thousand,one hundred and sixty billion!

Ken Johnson

 
Reply With Quote
 
Dana DeLouis
Guest
Posts: n/a
 
      5th Jan 2007
> ...every possible combination is displayed.

Hi. As others have mention, the output is too large.
A newer measure of large might be that you would have to completely fill
3,486,784,401 Columns in Excel 2007. (36^10/2^20) <vbg>
In Combinations, one is usually not interested in generating all
combinations. One is usually interested in generating only a few of the
outputs. One might be interested in the 1 millionth item in the list, or
perhaps pick a few items from the list at Random.
It is usually more efficient to generate the combinations as needed. The
function name usually goes by the name UnRank...(ie UnRankCombinations, or
something similar for your example)

The code below just demo's how this might be done for your 3 character
example.
Excel vba can easily find the 2456158341262976 th item from your 10
character example, but it requires a little modification.

Again, this is just a simple example...

Sub TestIt()
Debug.Print UnRank(1) 'First item in list
Debug.Print UnRank(46656)'Last item in list
Debug.Print UnRank(1372)' the 1372 th item in list
End Sub

Returns:
000
ZZZ
123

Function UnRank(Num As Double) As String
Dim n As Double
Dim Block As Double
Dim j As Long
Dim M As Double
Dim s(0 To 35) As String
Const k As Double = 36

For n = 0 To 35
s(n) = Chr((n + 48) - 7 * (n > 9))
Next n

'// Note: First item is 000
n = Num - 1
Block = k ^ 2

For j = 2 To 0 Step -1
M = Int(n / Block)
UnRank = UnRank & s(M)
n = n - M * Block
Block = Block / k
Next j
End Function

--
HTH :>)
Dana DeLouis
Windows XP & Office 2003


<(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hey! Here is the problem...I can't figure out how to make it so every
> possible combination of a series of letters (A-Z) and Numbers (0-9) is
> displayed I saw someones code to make it possible for three characters
> but I am looking to do it with like 10 characters...The code I saw was
> this...
>
> Sub comboo()
> Dim s(36) As String
> For i = 0 To 9
> s(i) = Chr(i + 48)
> Next
> For i = 10 To 36
> s(i) = Chr(i + 55)
> Next
>
>
> k = 1
> For i = 0 To 35
> For j = 0 To 35
> For l = 0 To 35
> Cells(k, "A").Value = s(i) & s(j) & s(l)
> k = k + 1
> Next
> Next
> Next
> End Sub
>
> Any ideas? Any help is much appreciated!!
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
3-character combinations? Allison Microsoft Excel Programming 3 20th Oct 2008 10:59 PM
Creating combinations =?Utf-8?B?c3dlZXRhczAx?= Microsoft Excel Misc 0 9th Nov 2007 03:21 AM
Re: Creating Combinations Roger Govier Microsoft Excel Worksheet Functions 0 9th Nov 2005 10:01 AM
Breaking URL character combinations GrantMagic Microsoft ASP .NET 2 22nd Oct 2004 05:14 PM
Re: Creating combinations Bernie Deitrick Microsoft Excel Misc 6 20th Feb 2004 07:44 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:56 AM.