Created
January 13, 2012 05:50
-
-
Save dekosuke/1604840 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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