Re: FASTEST way to try all strings (a until ZZZZZZZZZZZZZZZZZZZZZZZZ)

From: Jon Skeet [C# MVP] (skeet_at_pobox.com)
Date: 09/28/04


Date: Tue, 28 Sep 2004 09:21:06 +0100

DraguVaso <pietercoucke@hotmail.com> wrote:
> I need to find the FASTEST way to get a string in a Loop, that goes from "a"
> to "ZZZZZZZZZZZZZZZZZ".

Even using just 17 characters (unlike the last one you've given below)
there are a ridiculous number of combinations. You just *won't* be able
to test every one of them. With 53 symbols (a-z, A-Z, space) you get
205442259656281392806087233013 combinations.

Assuming you could process 100 *billion* of them every second, it would
still take you 65145313183 years to go through them all. Do you really
have that much time?

Now, as for speeding up what you've got: using a StringBuilder instead
of repeated string concatenation would be a good start. Alternatively
you could use a char array. (I haven't checked your actual algorithm
for correctness, btw.)

I note that you're using 52^30 as the number of possible combinations,
which I don't quite understand if you're including space, but even so,
that makes the length of time taken even greater.

Suppose you have a million computers *each* processing 100 billion
combinations a second, to get through 52^30 combinations I suspect
you'd have to wait until way after the sun had gone cold to see the
end.

In other words: you'll need to find a different way of approaching your
problem...

-- 
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too


Relevant Pages

  • Re: FASTEST way to try all strings (a until ZZZZZZZZZZZZZZZZZZZZZZZZ)
    ... DraguVaso wrote: ... Even using just 17 characters ... With 53 symbols (a-z, A-Z, space) you get ... of repeated string concatenation would be a good start. ...
    (microsoft.public.dotnet.languages.vb)
  • Re: 128 bit password
    ... If a password is for example 128bit, how long is it in characters (a-z ... If the password is "THISisMYpassword". ... It's the level of coding the security ...
    (microsoft.public.security)
  • preg_match allowing a-z AND å ä ö ü
    ... lowercase) characters of A-Z, 0-9 and for instance Swedish characters Å Ä Ö. ... but both returns false on everything except a-z A-Z. ... e-mail header causing the e-mail to fail. ...
    (comp.lang.php)
  • Re: small simple regexp favor
    ... anything other than A-Z 1-0 and also allow these 5 special characters?? ... Dim oRE: ... Dim nIdx, sMsg, sRes ...
    (microsoft.public.scripting.vbscript)
  • Re: small simple regexp favor
    ... anything other than A-Z 1-0 and also allow these 5 special characters?? ... Dim oRE: ... Dim nIdx, sMsg, sRes ...
    (microsoft.public.scripting.vbscript)

Quantcast