Forum Discussion
CEdward940
Oct 19, 2023Copper Contributor
Create an array that enumerates different combinations of percentages.
Hello, I would like to create an array that enumerates all of the different ways in which 100% can be split up between 13 different letters. Is there a quick and error-free way to do this that is...
Patrick2788
Oct 19, 2023Silver Contributor
This request has appeared on this site several times in a few different formats. To solve with a formula it's a matter of generating combinations and then selecting combinations that = target (1 in this case).
From the start I think you have to take repeats off the table for memory considerations.
For example, if your increment is .05 then the possible combinations (Equaling 1 and otherwise) is determined by:
=SUM(COMBINA(20,SEQUENCE(13)))
=573,166,439
This solution does not use any repeats:
=LET(
letters, 13,
header, CHAR(SEQUENCE(, letters, 65)),
step, 0.02,
step_array, SEQUENCE(, 100, step, step),
BinMatrix, MOD(
INT(SEQUENCE(2 ^ letters, , 0) / 2 ^ SEQUENCE(, letters, 0)),
2
),
StepMatrix, TAKE(BinMatrix * TOROW(step_array), , 13),
Combinations, FILTER(
StepMatrix,
MMULT(StepMatrix, SEQUENCE(letters, , 1, 0)) = 1
),
VSTACK(header, Combinations)
)