I have an unknown number with n digits without repetition. I have n sets with the allowed digits for each position. I need to know how many possibilities exist for the unknown number.
When the sets are identical I can just calculate the number of n permutations of the set size. For instance if n=4 and the sets are {1, 2, 3, 4, 5, 6}, I know there are 6! / (6 - 4) = 360 possibilities.
If the sets don't intersect at all I can just calculate the product of their sizes, so for n=4 and the sets {1, 2, 3, 4, 5}, {6, 7}, {8, 9}, {0} I know there are 5 * 2 * 2 * 1 = 20 possibilities.
My difficulty is in handling repeated digits with different sets, like for n=4 and the sets {1, 2, 3}, {3, 4, 5}, {4, 5, 6, 7}, {1, 2, 8, 9}. By generating all possibilities where no digit is repeated I know there are 84, but is there any way to calculate it?