You are here: Re: Combination or Permutation question! « PHP Programming Language « IT news, forums, messages
Re: Combination or Permutation question!

Posted by Alkimake on 03/29/06 15:28

Here is the answer that Oli found :)

function getCombinations($values)
{
$perms = array(null);
foreach ($values as $key => $v)
{
$temp = $values;
for ($i=0; $i<=$key; $i++) {
unset($temp[$i]);
}
$newPerms = getCombinations($temp);
foreach ($newPerms as $perm)
{
$perms[] = ($v . $perm);
}
}
return $perms;
}


By the way this code is perfect. i have never seen a solution like
this. Thank you very much Oli. And second thank is for making me think.
Actually i didn't want somebody to answer me completely because to
understand the algoritm is more more more important than copy & paste
for me. This is impressive.

Actually i did the combinations when i saw your message but it is about
120 lines :) and very slow.

Take care and see ya.

PS: if i had mistakes i am sorry cuz my english is not so good :)

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация