Re: string generation
- From: mwojcik@xxxxxxxxxxx (Michael Wojcik)
- Date: 23 May 2005 22:04:49 GMT
In article <lnvf5bvmag.fsf@xxxxxxxxxxxxxxx>, Keith Thompson <kst-u@xxxxxxx> writes:
> "Emmanuel Delahaye" <emdel@xxxxxxxxxxxxxx> writes:
> > Ken Human wrote on 22/05/05 :
> >> I want to generate every possible 16 character combination of the
> >> characters 0-9, A-Z, and a-z programatically. My current code
> >> follows:
> >
> > Really ? It may take hours or days to print them out... Sounds like a
> > cracking device...
>
> Hours or days? You'd better buy a sweater; it's going to get chilly
> after the sun burns out (which will happen long before this thing is
> finished).
Yes, but it still sounds like a cracking device, Dangermouse!
Of course, there's no need to generate them anyway. We already have
the list, in a handy compressed form that allows random access. Just
pick an integer between 0 and 62**16-1 and convert it into its base-
62 representation. A function implementing that algorithm serves as
the "array" of values, and its parameter as the "index".
Iteration is slower than iterating through an actual array, but since
constructing the actual array is, er, infeasible, that hardly matters.
(64 characters would actually be better here, since converting a
number in "pure binary" representation to base 64 is easier than
converting to base 62, but neither is difficult.)
--
Michael Wojcik michael.wojcik@xxxxxxxxxxxxxx
Push up the bottom with your finger, it will puffy and makes stand up.
-- instructions for "swan" from an origami kit
.
- Follow-Ups:
- Resolving a macro (was: string generation)
- From: CBFalconer
- Resolving a macro (was: string generation)
- References:
- string generation
- From: Ken Human
- Re: string generation
- From: Emmanuel Delahaye
- Re: string generation
- From: Keith Thompson
- string generation
- Prev by Date: How to determine the local port?
- Next by Date: Re: which is faster ?
- Previous by thread: Re: string generation
- Next by thread: Resolving a macro (was: string generation)
- Index(es):
Relevant Pages
|