Jump to content
  • Advertisement
Sign in to follow this  

Algoritihm to list a million terabytes of info

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

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
Advertisement
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 * c
long long Number

*c = &number

printf("%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 this post


Link to post
Share on other sites
Quote:
Original post by vaneger
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?


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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!