Advertisement
Guest User

Untitled

a guest
Jun 25th, 2017
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.45 KB | None | 0 0
  1. <?
  2. echo "all combination\n";
  3.  
  4. function printAllCombinationsRecursive($prefix, $levelsLeft) {
  5.   if ($levelsLeft==0)
  6.     echo $prefix . '\n';
  7.   else
  8.     foreach ($letter in array={'a','b','c','d'}) {
  9.       printAllCombinationsRecursive($prefix.$letter,$levelsLeft-1);
  10.     }
  11. }
  12. function printAllCombinationsUpToLength($levels) {
  13.   for ($i=1 $i<$levels; $i++} {
  14.     printAllCombinationsRecursive("",$i);
  15.   }
  16. }
  17. printAllCombinationsUpToLength(24);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement