Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 08-10-2011, 05:42 PM Combinatoric
Junior Talker

Posts: 1
Trades: 0
Hello guys,

I have script
PHP Code:
<?php

    
function Permutate($strDataIn$Length, &$PermutateCount)
    {
        for (
$i 0$i strlen($strDataIn); $i++)
        {
            
$PermArray[0][$i] = substr($strDataIn$i1);
            
$temp[$i] = substr($strDataIn$i1);
            
$temp2[0][$i] = substr($strDataIn$i1);
        }
       for (
$i 1$i $Length$i++)
       {
            for (
$k 0$k strLen($strDataIn); $k++)
            {
                for (
$j 0$j sizeof($temp2[$i 1]); $j++)
                {
                    
$PermArray[$i][($k sizeof($temp2[$i 1])) + $j] = $temp[$k] . $temp2[$i 1][$j];
                    
$temp2[$i][($k sizeof($temp2[$i 1])) + $j] = $temp[$k] . $temp2[$i 1][$j];
                }
            }
        }
        
$k 0;
        for (
$i 0$i $Length$i++)
        {
            
$k += sizeof($PermArray[$i]);
        }
        
$PermutateCount $k;
        return 
$PermArray;
    }
    
     
$StartString "ABCDEFGHI";
     
$len 4;
     
$Return Permutate($StartString$len$cnt);
     
     
$i $len -1;
     
     
$cnt sizeof($Return[$i]);
   
    
$File "AAAA.txt";
     
$f fopen($File'w');

     
     print 
"Returned <b>$cnt</b> permutations.<br><hr>";
     
     
//for ($i = 0; $i < $len; $i++)
     //{
        
for ($j 0$j sizeof($Return[$i]); $j++)
        {
            
fwrite ($f$Return[$i][$j] . "/n");
           
        }
         print 
"<br>";
         
          

     
//}
?>
How to change it for unique combinations like
ABCD ABDC ACBD ACDB ADBC ADCB
BACD BADC BCAD BCDA BDAC BDCA
CABD CADB CBAD CBDA CDAB CDBA
DABC DACB DBAC DBCA DCAB DCBA ?
G1ntas is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 08-10-2011, 07:44 PM Re: Combinatoric
Physicsguy's Avatar
404 - Title not found

Posts: 920
Name: Scott Kaye
Location: Ontario
Trades: 0
Are you trying to crack a password? Believe me, I've tried, and PHP is definitely not the best solution.
__________________
Check out my
Please login or register to view this content. Registration is FREE
or my
Please login or register to view this content. Registration is FREE
!
Physicsguy is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Combinatoric
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.65633 seconds with 12 queries