I tried to simplify the task as much as possible, so I could apply it to my algorithm.
And here is the task for mathematicians and programmers:
I need to create a method in which I pass an int n parameter:
public void optionality_generator(int n){
The output should display all possible combinations of true and false.
Here are examples where N = 1; N = 2; N = 3; N = 4; N = 5, where x = false and 0 = true; Please note: empty interrupt lines are just for you to make it easier to recognize patterns. Hope I have included all possible combinations):
Combination of 1: 0 x Combination of 2: 00 x0 0x xx Combination of 3: 000 X00 0X0 00X XX0 0XX XXX Combination of 4: 0000 X000 0X00 00X0 000X XX00 X0X0 X00X 0XX0 0X0X 00XX XXX0 XX0X X0XX 0XXX XXXX Combination of 5: 00000 X0000 0X000 00X00 000X0 0000X XX000 X0X00 X00X0 X000X X0X00 X00X0 X000X 0XX00 0X0X0 0X00X 00XX0 00X0X 000XX XXX00 XX0X0 XX00X X0XX0 X0X0X X00XX 0XXX0 0XX0X 00XXX XXXX0 XXX0X XX0XX X0XXX 0XXXX XXXXX
In addition, if you see the conclusion, here is a sign that I recognized that all combinations are inverted in half (for example, the first combination 00000 will be XXXXX last, the second X0000, one to the last - 0XXXX, etc. ...). Perhaps this template will help make the whole algorithm more efficient, not sure about it. Thank you in advance!
source share