$3$ digits numbers in which digits are repeated. 
Total number of $3$ digit number which can be formed by using the digits $1,2,3,4,3,2,1$

$\bf{My\; Try::}$ Total no. of $3$ digits numbers in which exactly $2$ digits are identical, are
$112,113,114,221,223,224,331,332,334$
So Total numbers of $3$ digits numbers are $\displaystyle \frac{3!}{2!}+\frac{3!}{2!}+\frac{3!}{2!}+\frac{3!}{2!}+\frac{3!}{2!}+\frac{3!}{2!}+\frac{3!}{2!}+\frac{3!}{2!}+\frac{3!}{2!}$
So we get sum $ = 27$
And Total no. of $3$ digits numbers in which all digits are distinct,are
$123,124,234,341$
So Total numbers of $3$ digits numbers are $\displaystyle3!+3!+3!+3!=24$
So we get Total $ = 27+24=51.$
Is my solution is right, If not Then how can I calculate It, Thanks
 A: Your solution is correct, but tedious and runs the danger of missing something due to carelessness.
You could have worded it instead as breaking it into cases.


*

*case1: a repeated number

*case 2: no repeated numbers  


In each case, approach via multiplication principle.
Counting case 1: pick which number repeated, pick nonrepeated, pick location of nonrepeated: $3\cdot 3\cdot 3=27$.
Counting case 2: pick number in slot one, in slot two, in slot three: $4\cdot 3\cdot 2=24$.
This gives, as you already found, $27+24=51$ total arrangements.
A: Yes, your solution is correct.  In the second case, you want to find the number of 3 digit numbers with distinct digits where the digits are taken from $\{1,2,3,4\}$. This number is just $P(4,3)=4 \times 3 \times 2 = 24$ because the first digit can be chosen in 4 ways, the second in 3 ways (since the second digit can be any digit except the first digit), and the third digit can be chosen in 2 ways (since it can be any of the four digits available except the two digits chosen for the first and second positions). 
