Hi PerlMonks,
It might be a silly question. But I donot find a simple perl code to solve this problem. I have an array like @a=qw/A B C D/; and I'm interested to get all possible permutations of say 3 elements out of 4 in the array and their total numbers i.e. 4p3=4!/(4-3)!=24 permutations along with 4 other uniform permutations (i.e. AAA,BBB, CCC,DDD). Thus total number of permutations will be 24+4=28. I need the permutations like ABC,ABD,BCD .. DDD and their total numbers (28). I have gone through some posts but nowhere I find the answer to this type of basic question. May I request the Perlmonks to provide suggestions for this problem? I am sure that I have put a very silly question. Moreover, the code must work for permutations of 2 or 4 elements out of 4 i.e. 4p2 and 4p4 along with their uniform permutations with little change in the code.
In reply to How can one generate all possible permutations of r elements out of n where r<n? by supriyoch_2008
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |