[Tutor] All possible 16 character alphanumeric strings?
steve at pearwood.info
Sun Sep 16 05:20:11 CEST 2012
On 16/09/12 13:06, akleider at sonic.net wrote:
> #!/usr/bin/env python
> # file : every.py
> print 'Running "every.py"'
> possible = "234567abcdefghijklmnopqrstuvwxyz"
> word_length = 16
> word_list = 
> def add_word(word):
> if len(word)==word_length:
> print word # There may come a time you won't want this line.
> for c in possible:
> new_word = word + c
> # print word_list
> There won't be any whitespace or commas in any of the derived output.
> For your purposes, you might want to make this into a generator although
> that would be getting too sophisticated for me to help you.
> Since in its present form the algorithm is a recursive one, I'm guessing
> it'll run out of memory long before it comes to completion although I
> haven't let it run for more than a few seconds,
There are 32**16 = 1208925819614629174706176 16-character strings using
digits 2-7 and lowercase a-z. To store a full list of them all will take
at least 74953400816107 terrabytes of memory. Given that even high-end
IBM Blade servers don't support even a single terrabyte of RAM, I think
that your guess about running out of memory is pretty safe...
More information about the Tutor