hi,

if i have a 4-digit number 1234, the total permutations is 24, ie there're 24 different 4-digits possible from the digits 1, 2, 3 and 4.

likewise, a 4-digit number with 2 same digit has total of 12 permutations.
for eg, 1123 has 12 permutations

numbers with two sets of same digit has total 6 permutations
for eg, 1122 has 6 permutations

numbers with 3 same digits has 4 permutations
for eg, 1112 has 4 permutations

my question how can i list out all the possible permutations?
like this:

1234 1123 1122 1112
1243 1132 1212 1121
1324 1213 1221 1211
1342 1231 2112 2111
1423 1312 2121
1432 1321 2211
2134 2113
2143 2131
2314 2311
2341 3112
2413 3121
2431 3211
3124
3142
3214
3241
3412
3421
4123
4132
4213
4231
4312
4321


actually i've done it, the hard way
would like to know the more efficient way.

thanks,