sug15 Posted September 22, 2009 Share Posted September 22, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/175068-solved-generating-all-possible-combinations/ Share on other sites More sharing options...
Alex Posted September 22, 2009 Share Posted September 22, 2009 I'm not sure you realize exactly how large of a list that would be. It would take a very long time to process every combination as there are 340282366920938000000000000000000000000 different combinations. Quote Link to comment https://forums.phpfreaks.com/topic/175068-solved-generating-all-possible-combinations/#findComment-922672 Share on other sites More sharing options...
Psycho Posted September 22, 2009 Share Posted September 22, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/175068-solved-generating-all-possible-combinations/#findComment-922685 Share on other sites More sharing options...
Mark Baker Posted September 22, 2009 Share Posted September 22, 2009 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? Quote Link to comment https://forums.phpfreaks.com/topic/175068-solved-generating-all-possible-combinations/#findComment-922768 Share on other sites More sharing options...
Daniel0 Posted September 22, 2009 Share Posted September 22, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/175068-solved-generating-all-possible-combinations/#findComment-922781 Share on other sites More sharing options...
sug15 Posted September 23, 2009 Author Share Posted September 23, 2009 Alright, thanks. I figured it out, but I was was just wondering for an expiriment I was doing. I wasn't actually planning on generating them all Quote Link to comment https://forums.phpfreaks.com/topic/175068-solved-generating-all-possible-combinations/#findComment-923738 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.