Jump to content

[SOLVED] Generating all possible combinations


sug15

Recommended Posts

Let's say I have an array:

array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f');

And I want to generate all possible outcomes of the array that are 32 characters, yes I know this will be a huge list.

For example it would generate:

00000000000000000000000000000000

00000000000000000000000000000001

all the way up to

fffffffffffffffffffffffffffffffd

ffffffffffffffffffffffffffffffff

 

And after each time one is generated, echo it, or do something. I have tried to do this, and can only really do it by generating a random one after another, but obviously that's not the best way. Does anyone know how? Thanks.

Link to comment
Share on other sites

The logic of what you are asking is fairly simple, but as AlexWD has pointed out it would just be a theoretical exercise as you would need the computing power of a million deep blue's or maybe several million cuda enabled GPUs in order to accomplish this before the sun exploded.

 

To complete this process in one year's time the computer would have to process roughly 10,790,283,070,806,014,188,970,529,154,990 records per second! Assuming, your system could process 1 million records a second (which I doubt it can) it would take 10,790,283,070,806,014,188,970,529 years to process all the combinations. To put that into perspective, the earth is believed to be only 4,500,000,000 years old.

Link to comment
Share on other sites

I really am looking forward to the next release of Quantum-PHP, when a variable can have every single possible value, all at the same time.

 

 

I seem to recall a similar request a few months back, but can't find the thread; but IIRC the OP in that thread simply wanted a single random value when questioned about it. He was trying to build an array of all possible values, and then randomly select one of those values.

 

What does the OP of this thread really want?

Link to comment
Share on other sites

To complete this process in one year's time the computer would have to process roughly 10,790,283,070,806,014,188,970,529,154,990 records per second! Assuming, your system could process 1 million records a second (which I doubt it can) it would take 10,790,283,070,806,014,188,970,529 years to process all the combinations. To put that into perspective, the earth is believed to be only 4,500,000,000 years old.

 

He'll also require a lot of storage and/or RAM.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.