Jump to content

Help with permutations.


Jragon

Recommended Posts

Hiya guys,

 

I've never used 'Hiya' =]

 

Well, I need a little help. I've got a permutation function that Mchl gave me:

function permute($array,$positions,&$perms,$previous = null) {
  if($positions > 0) {
   if(!isset($previous)) {
     $previous = array();
   }
   
    foreach($array as $element) {
     $tempPrevious = $previous;
     $tempPrevious[] = $element;
     permute($array,$positions-1,$perms,$tempPrevious);
   }
  } else {
    $perms[] = $previous;
  }
}

 

It works fine, but I need to take it to the next level (you might not call it permutation). What I need it to do:

  • Use's all characters in ASCII thing
  • start from 1 characters and goto 50 characters
  • When it gets to Maximum execution time it remembers where it was and can be restarted and will start form there
  • MD5 the output
  • Add the md5 hash to a database with the origanal output
  • Work

 

So that is what I need it to do. If it is possible Please tell me how it can be done, if not then tell me how much of it is possible.

 

Thanks

 

Jragon

Link to comment
https://forums.phpfreaks.com/topic/209824-help-with-permutations/
Share on other sites

  • 3 weeks later...

permutations are similar to changing number base.

 

permutation number = 5

n (options) = a and b

 

keep removing from left to right, the highest value of n you can, times it by position from right * n each row.

 

think of it like change, if we have a 1p 2p 5p 10p 20p 50p coins

 

and i want 57 pence, you keep removing the biggest coin you can, 50, (leaving 7) 5, leaving 2, and 2 leaving 0

 

so 50 + 5 + 2 pence coins.

 

i'm in a rush, sorry.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.