Sorry if this has been asked before, tried to look through older answers but don't get any of the formulas there and don't understand the questions asked either.
I would like to calculate possible combinations for a given set of data:
There is an x amount of columns (let's say 3) each column contains y amount of words (lets say 2), now I would like to calculate total amount of combinations possible.
For example: column 1 contains "one" and "two", column 2 contains "three" and "four", column 3 contains "five" and "six" then all possible combinations are:
["one", "three", "five"], ["one", "three", "six"], ["one", "four", "five"], ["one", "four", "six"],
["one", "five", "three"], ["one", "five", "four"], ["one", "six", "three"], ["one", "six", "four"],
["two", "three", "five"], ["two", "three", "six"], ["two", "four", "five"], ["two", "four", "six"],
["two", "five", "three"], ["two", "five", "four"], ["two", "six", "three"], ["two", "six", "four"],
["three", "one", "five"], ["three", "one", "six"], ["three", "two", "five"], ["three", "two", "six"],
["three", "five", "one"], ["three", "five", "two"], ["three", "six", "one"], ["three", "six", "two"],
["four", "one", "five"], ["four", "one", "six"], ["four", "two", "five"], ["four", "two", "six"],
["four", "five", "one"], ["four", "five", "two"], ["four", "six", "one"], ["four", "six", "two"],
["five", "one", "three"], ["five", "one", "four"], ["five", "two", "three"], ["five", "two", "four"],
["five", "three", "one"], ["five", "three", "two"], ["five", "four", "one"], ["five", "four", "two"],
["six", "one", "three"], ["six", "one", "four"], ["six", "two", "three"], ["six", "two", "four"],
["six", "three", "one"], ["six", "three", "two"], ["six", "four", "one"], ["six", "four", "two"]
That's 48 if I'm not mistaken. What I'm stuck with is how I can calculate that.
Using only vertical combinations (columns don't switch) I get 2X2X2 is 8 so when switching columns its 6 times more but adding one more column gives me 384 results thats 24 times more (2X2X2X2).
I was programming this in JavaScript and think I got the results right but how would I go about calculating expected results?
I tagged this homework as I have no clue how to tag this.
Best Answer
Assuming all the words are different, then you will have $y^x x!$ different possibilities.
$2^3 3! = 48$, $2^4 4! = 384$.
To see this, first fix the $x$ columns, each of which is selected from $y$ words. This gives $y^x$ possibilities. There are $x!$ possible permutations of the columns, hence you have $y^x x!$ different possibilities.