# Algoritihm to list a million terabytes of info

This topic is 4976 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

i need help figuring out an algorithm that can list all the possible combinations of an 8 element array of characters (0-255) or in otherwords 256^8 combinations. The algorithm needs to list each possible combination in a linear way (never mind that no computer on earth can hold all of the data that part is irrelevant). How do i create a loop that can do this? for example listing 0 0 0 0 0 0 0 0 (now list all possiblities with the 8th element assumed as 0) 0 0 0 0 0 0 1 0 0 0 0 0 0 0 2 0 ..... until every possiblity with the 8th element being 0 is listed then continue on assuming the 8th element to be 1 and increment the listing like that until the 8th element is assumed to be 255 and all of those possiblities are listed.

##### Share on other sites
There are a few ways

Once of the easiest is to get the entirety of it into a single giant bit array.

You increment the bit array (its 64 bits long, so you just use a long long).

once it hits 111.....1 then you exit
To display the numbers, you do

char * clong long Number*c = &numberprintf("%c %c %c %c %c %c %c %c", c[0] + '0', c[1] + '0', c[2] + '0', c[3] + '0', ....)

Thats the simplest you can get. Although there are faster ways

And btw, it will output 1,844,644,073,709,551,616 Entries.
Thats one quintillion, eight hundred and fourtyfour quadrillion, Six hundred fourty four trillion, Seventy Three billion, Seven hundred and nine million, five hundred and fifty five thousand, Six hundred sixteen. Entries. What are you going to do with that?

Now, with a midium-Largish Distrobuted computer, you can compute that many entries. I don't see the point tho..

From,
Nice coder

[Edited by - Nice Coder on January 3, 2005 11:33:48 PM]

##### Share on other sites
Quote:
 Original post by vanegeri need help figuring out an algorithm that can list all the possible combinations of an 8 element array of characters (0-255) or in otherwords 256^8 combinations. The algorithm needs to list each possible combination in a linear way (never mind that no computer on earth can hold all of the data that part is irrelevant). How do i create a loop that can do this?

Well I have to say that your comment about no computer on Earth raises a red flag. Please tell us why you are asking this question here, and review the Forum FAQ for the policy on non-game-development problems.

1. 1
2. 2
3. 3
4. 4
5. 5
frob
11

• 12
• 16
• 13
• 20
• 12
• ### Forum Statistics

• Total Topics
632175
• Total Posts
3004585

×