Lets suppose that the numbers that the spy saw were 1,2,3,4,5,6 and by the question we know that the password has 7 digits, meaning that one of those number repets itself. We dont know wich one repets, so we need to keep that in mind. First, lets imagine that the number 1 repeats, so one of the possibilities is:
[tex]1123456[/tex]We can see that to find all the possibilities of passwords with 1 repeating is a permutation with repetition. So the amount of passwords that we can have is:
[tex]\text{Passwords with 1 repeating=}\frac{7!}{2!}=7\times6\times5\times4\times3=2520[/tex]Now, we just need to calculate the possibilities when 2,3,4,5 or 6 repeats:
[tex]\text{Passwords with 2 repeating=}\frac{7!}{2!}=7\times6\times5\times4\times3=2520[/tex][tex]\text{Passwords with 3 repeating=}\frac{7!}{2!}=7\times6\times5\times4\times3=2520[/tex][tex]\text{Passwords with 4 repeating=}\frac{7!}{2!}=7\times6\times5\times4\times3=2520[/tex][tex]\text{Passwords with 5 repeating=}\frac{7!}{2!}=7\times6\times5\times4\times3=2520[/tex][tex]\text{Passwords with 6 repeating=}\frac{7!}{2!}=7\times6\times5\times4\times3=2520[/tex]So, in total we have 15120 possibilities of passwords, so the probability of a spy getting the password first try is:
[tex]probability\text{ first try=}\frac{1}{15120}[/tex]