Probability of guessing a PIN-code A friend and I recently talked about this problem:
Say my friend feels a little adventurous and tells me that exactly three of four digits of his PIN-code are the same, what is the probability that I will guess it in three tries?
At first I thought this shouldn't be too difficult to count, but the digit restriction threw me off. Essentially I want to count how many possible PIN-codes there are with the restriction that $3$ of $4$ digits are the same. I tried thinking in terms of using sums, but I got stuck. I actually ended up making a quick MATLAB-script that computed the number of possible PIN-codes using a brute force method. Assuming that my script is correct there are $360$ codes that abide by this restriction out of a total of $10^4=10\hspace{4 px}000$ possible PIN-codes. Using this it is easy to calculate the rest, but I am now wondering how one might go about this in a more elegant way.
A PIN-code is a $4$-digit number where the possible digits are $0,1,2,...,9$. So for my question two examples of possible codes are $3383$ and $2999$. Let's assume that there are no further restrictions, although in reality there likely are, and that each digit is equally likely. It is important to note that I do not know if it is $0,1,...,8$, or $9$ that appears three times.
This question is not homework or anything, it is really just for curiosity. Thanks for any help!
(By the way I saw this question: Combinatorics and Probability Problem but it did not help me.)
EDIT: I made an error in my script. Updated.
 A: Suppose $n$ is repeated. There are 9 other numbers that can occur. And the other digit can occur in 4 possible positions giving $36$ possibilities. 
There are $10$ possibilities for $n$ so the total number of combinations with exactly three digits the same is $360$. 
A: There are ten choices for the repeating digt, nine choices for the different digit, and four choices for its position. Hence there are indeed $10\cdot 9\cdot 4=360$ matching PINs.
A: The way I approached the problem is to break it down into three possibilities. The repeating number from $0,1,...,9$ with ten possibilities. The unique number $0,1,...,9$ excluding the first pic, so nine possibilities. After that the location of the unique number in the combination which can be $1,2,3,4$ for four possibilities.
This gives us $10*9*4 = 360$ different possible combinations which match your conditions.
A: $4$ possibilities for position of the digit that is different from all
others.
$10$ possibilities for this digit itself.
$9$ possibilities left for  the three others.
That gives $4\times10\times9=360$ possibilities. 
A: Number of possibilities:


*

*The repeated number has 10 options.

*The forth number has 9 possibilities remaining.

*The forth number can be found in each of the four places of the PIN number (4 options)
thus, we get: 10*9*4 = 360.


Probabilities:
The probability of guessing the PIN code in one try is simply: 1/360.
The probability of failing is: 359/360.
Using Bernoulli trials formula:
The probability of guessing the PIN code in exactly the third try is: (1/360)^3.
But the probability of guessing the PIN code in exactly one of 3 tries is: 3*(359/360)^2*(1/360)
A: 10000 guesses that would be including double and triple and four same number 
0000,0001,0002, 1000 ,1111,2245 ,5001  ,8768 ,9990.  .eg
So the chance of get a four number pin is 1 in 10, 000 that's is 0000 is included 
