Click here to Skip to main content
15,908,906 members
Please Sign up or sign in to vote.
2.50/5 (3 votes)
See more:
hi, I am making an application but i am stuck in one module,

i simply want to make a Method like

private string Hitter()
{
Some Code
}


which will return all possible combinations of the following

abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890~!@#$%^&*()_+=-`';.,?/<>:"{}|\][


Is it Possible ?, I feel it will be....:~

Please Guide me:confused:
Posted

It is virtually impossible. Or, in other words, it is possible to write such algorithm, but you have a very slim chance that you (or your grand-grandsons) will still be alive when the algorithm finishes.

You have a set of approximately 100 characters. There are approximately 10^28 50-combinations (10^28 ways to choose 50 items out of 100). No matter how efficient your algorithm is, it will take forever to generate 10^28 items. Not speaking about all 49-combinations, 48-combinations, 47-combinations...

Maybe you meant permutations instead of combinations. Well, if that's the case, then your situation is not any better, since there are about 10^157 permutations... Well, I wish you a lot of patience with that.
 
Share this answer
 
Comments
Toli Cuturicu 6-Oct-10 14:57pm    
Well said, answerer!
Sorry, OP.
Check this article:

Permutations, Combinations, and Variations using C# Generics[^]

Or google "c# permutations"
 
Share this answer
 
You should use Random class of c# for this.

http://www.c-sharpcorner.com/UploadFile/mahesh/RandomNumber11232005010428AM/RandomNumber.aspx[^]

Please Vote if this helped you then.
 
Share this answer
 
Comments
nakulkundra 6-Oct-10 9:31am    
random function will not ensure all possible combinations in optimal time
Toli Cuturicu 6-Oct-10 14:56pm    
Absurd, illogic, worst answer ever. Less then 1 deserved.
Sandeep Mewara 6-Oct-10 15:12pm    
How come random function will do?
NMehta83 7-Oct-10 2:22am    
Please see the link you will get it. Just need to add more ascii value into that to get exact output.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900