I see that some very similar questions have been answered, perhaps some more general answer contains my question.
I was asked how many combinations there would be if exactly 3 digits are used for a 4 digit pin code. I reasoned in the following way but I am not completely sure I have thought of everything. Rather than taking the combinations in order of appearance (which I initially tried to but failed) I looked at the doublets:
Any combination will contain one number doubled since all three digits must be used. The doublets can occur for a number of combinations, like the lines of the sides in a square with number of diagonals added, i.e. in 6 ways. The 3 doublets (1,1) (2,2) and (3,3) arranged in 6 ways allows for 18 combinations.
For everyone of these the remaining two digits can be arranged I 2 ways such as for example after the doublet (1,1) must come (2,3) and (3,2). This gives me 2*18=36 combinations.
Does this look reasonable to you?