Created
August 20, 2016 06:45
-
-
Save Bamuel/73aa55217fbe0d9208795495ecebcbec to your computer and use it in GitHub Desktop.
combinations at its finest
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 limit ($n, $input) { | |
if ($n > 0) { | |
$tmp_set = array(); | |
$res = limit($n-1, $input); | |
foreach ($res as $ce) { | |
foreach ($input as $e) { | |
array_push($tmp_set, $ce . $e); | |
} | |
} | |
return $tmp_set; | |
} | |
else { | |
return array('→ '); | |
} | |
} | |
$input = array('0','1','2','3','4','5','6','7','8','9'); | |
$input2 = limit(4, $input); | |
echo "The Epic List <br>"; | |
foreach($input2 as $output) { | |
print $output . "<br>"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment