1. ## Combinations problem

This may involve mods.

4 digit security codes in a particular city have this property:
the 4th digit is always the last digit of the sum of the first 3 digits. E.g. 3452, where 3 + 4 + 5 = 12, and 2 is the last digit of 12. Other examples include 5544.

There cannot be a security code with more than two consecutive digits the same (i.e. 6668 is not allowed, but 5544 is). How many different codes can be used?

Thanks in advance for any help.

2. Originally Posted by BG5965
This may involve mods.

4 digit security codes in a particular city have this property:
the 4th digit is always the last digit of the sum of the first 3 digits. E.g. 3452, where 3 + 4 + 5 = 12, and 2 is the last digit of 12. Other examples include 5544.

There cannot be a security code with more than two consecutive digits the same (i.e. 6668 is not allowed, but 5544 is). How many different codes can be used?

Thanks in advance for any help.
Hi BG5965.

First consider codes in which the first three digits are $\displaystyle xyy$ with $\displaystyle x\ne y.$ Then $\displaystyle x+y+y\equiv y\pmod{10}\ \iff\ x+y\equiv0\pmod{10}.$ For each $\displaystyle x$ except 0, there is exactly one $\displaystyle y$ such that $\displaystyle x+y$ is divisible by 10. Hence there are 9 such codes beginning with 0 allowed $\displaystyle (y$ can be any digit except 0). There are also 9 such codes beginning with 5 allowed $\displaystyle (y$ can be any digit except 5). For each code starting 1, 2, 3, 4, 6, 7, 8 and 9, there are 8 such codes allowed $\displaystyle (y$ can be any digit except $\displaystyle x$ and $\displaystyle 10-x).$ So the total number of allowable security codes beginning $\displaystyle xyy$ is $\displaystyle 9+9+8\times8=82.$

The number of security codes beginning $\displaystyle xxy$ with $\displaystyle x\ne y$ is 10 × 9 = 90. Similarly for codes beginning $\displaystyle xyx$ with $\displaystyle x\ne y.$ And the number of security codes in which the first three digits are distinct is 10 × 9 × 8 = 720.

Hence the total number of allowable security codes is 82 + 90 + 90 + 720 = 992.

3. Hi, I also posted this question on

and got different answers with different working.

I am quite confused on which is the right method!

4. Originally Posted by BG5965
Hi, I also posted this question on

and got different answers with different working.

I am quite confused on which is the right method!
Hi again.

The second poster who replied to your post over there assumed that your security code cannot start with 0 whereas the first one assumed that it can. Hope this explains why they are different.

5. Ok, but can you still re-explain the answer briefly - I don't get his explanation fully.

BG

6. Sorry, I'm even more confused now. So the answer is not 982, like on the other post on the other website?

7. Hi yet again.

The solution I originally posted was totally wrong. I have re-edited my post now, and I hope it’s better this time. The answer I have is 982. (Note that I am assuming that a security code can start with 0.)

8. Thanks a lot

I finally understand it now and I think now the answer is correct.