Number of ways possible to form a number?

300 Views Asked by At

Suppose we need to form a 4 digit number with the restriction that

At 1000th place only : 3 5 7 can come
At 100th place only  : 8 9 3 can come
At 10th place only   : 6 8 9 can come
At unit place        : 5 3 8 can come 

and also no two places can have same digit so 3365 is invalid but 3865 is perfectly valid. And can it be generalized for a n digit number with n places having m different options. Edit : Numbers on each place are distinct that is if at unit place 5 3 8 has come than they cannot come again so 5 3 8 3 is invalid(this is for generalization.)

1

There are 1 best solutions below

2
On

For your main question, I don't see anything easier than counting. There are only $3^4=81$ possibilities before you enforce the no duplicates, so try them all. For the generalization, it feels like it should be NP-complete, very similar to 3-SAT, which says there will (probably) not be anything easy.