Skip to content

Instantly share code, notes, and snippets.

@chestergrant
Created April 10, 2011 11:00
Show Gist options
  • Save chestergrant/912248 to your computer and use it in GitHub Desktop.
Save chestergrant/912248 to your computer and use it in GitHub Desktop.
Word Descrambler - PHP
<?
$arr = keypadsArr("h,e,s,s,c");
echo "Created by: Chester Grant \n";
echo "Purpose: Unscrambles letters(see line 199)\n";
echo "Date: 9th/04/2011\n";
combination("",0,$arr);
function combination($output,$pos,$dataSet){
if($pos == count($dataSet)){
echo $output."\n";
return;
}
for($i=0; $i < count($dataSet);$i++){
$ltr = $dataSet[$i];
if(substr_count($output,$ltr)<substr_count(implode($dataSet),$ltr )){
$new_output = $output.$dataSet[$i];
combination($new_output,$pos+1,$dataSet);
}
}
}
function keypadsArr($str){
return $arr1= explode(",",$str);
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment