Vote count:
-1
I have letters, from 'a' to 'v' (22 char input). I would like a result of, all possible sets of those numbers in a set size of 3.
I would like to see the solution made in PHP that could print out the result. I do not know the formula to calculate how many permutations that will be?
$input = array("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v");
Example sets:
a-a-a
a-a-b ..
a-b-c
a-c-b
b-a-c
b-c-a
c-a-b
c-b-a
a-b-d
and so on... v-v-v
Hoping it is easy to modify to result a set size of 2 as well.
a-a
a-b
b-a
a-c
and so on... v-v
Thanks So Much ^^,
asked 11 mins ago
1 Answer
Vote count:
0
<?php
for($i = 'a' ; $i<='v';++$i)
for($j = $i ; $j<='v';++$j)
for($k = $j ; $k<='v';++$k)
{echo $i.$j.$k;
echo '<br>';
}
?>
this will do :)
answered 2 mins ago
Permutations of a limited set size in PHP
Aucun commentaire:
Enregistrer un commentaire