Clear questions and runnable code
get the best and fastest answer
Combinations with variable lengthby TryingTheBest (Initiate)
|on May 10, 2021 at 20:54 UTC||Need Help??|
TryingTheBest has asked for the wisdom of the Perl Monks concerning the following question:
I am working with a combination script that is giving me problems.
This is as below:
I have two static numbers: 1 and 2.
And also I have a non-static number that represent the size of the combinations.
Example: 3 (combinations of 3 characters).
I need to perform ALL combinations using the static number, but considering the non-static number.
In the example with "3" as non-static number, this will be:
1 1 1 1 1 2 1 2 1 1 2 2 2 1 1 2 1 2 2 2 1 2 2 2
( I think I don't forget any combination :P )
Someone can help me with the code, please? I tried using use Algorithm::Combinatorics qw( combinations ); but I could not solve it.