Iterate once and only once through all the possible configurations of an array

to work out total combinations you need to understand what operations you are going to do. Say you are picking from a set value which can be reused then you would calculate x^y, x will be the number of choices you can make and y being the number of times you are allowed to make a choice. The number of choices remains the same as all probabilities are still available each time you choose. ( Think putting a card back into the deck, throwing a dice or flipping a coin).
If the choices cannot be reused then you would use the factorial to find out your max combinations, ie;

pick a card from a set of cards and then do not put your choice back in the deck.

52 total cards so 52! max combinations if you decide that you have t make 52 choices.

If you are making less than 52 choices then you have to amend the factorial calculation. We know that to calculate factorial we have to do
totalChoices * (maximumChoices - currentChoice) currentChoice
being the number of times we have already chosen. And finally we multiply our last answer with any new choices, giving us.

totalChoices * maxChoicesAllowed((maximumChoices - currentChoice) currentChoice)

then you can combine your knowledge of everything discussed to calculate the maximum allowed combinations for you current problem.

1 Like