Skip to content

Instantly share code, notes, and snippets.

@dekosuke
Created January 13, 2012 05:50
Show Gist options
  • Save dekosuke/1604840 to your computer and use it in GitHub Desktop.
Save dekosuke/1604840 to your computer and use it in GitHub Desktop.
<?php
function mkPerms($temp, $alphabet, $depth){
if($depth==0){ return array($temp); }
else{
$ret = array();
foreach($alphabet as $a){
$ret = array_merge($ret, mkPerms($temp.$a, $alphabet, $depth-1));
}
return $ret;
}
}
$a = array("A","C","G","T");
$perms = mkPerms("",$a, 5);
foreach( array_filter($perms, function($a){ return strstr($a, "AAG")!==false; })
as $ans ){
echo $ans."\n";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment