Created
February 11, 2016 13:45
-
-
Save AndyNovo/eba4e5e2b16214599c29 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
$myrack = "AAABNN"; | |
$racks = []; | |
for($i = 0; $i < pow(2, strlen($myrack)); $i++){ | |
$ans = ""; | |
for($j = 0; $j < strlen($myrack); $j++){ | |
//if the jth digit of i is 1 then include letter | |
if (($i >> $j) % 2) { | |
$ans .= $myrack[$j]; | |
} | |
} | |
if (strlen($ans) > 1){ | |
$racks[] = $ans; | |
} | |
} | |
$racks = array_unique($racks); | |
print_r($racks); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment