Combinatorics with repetition problem I am not sure about my solution on this problem:
The password with 8 characters: numbers or upper case letters of
english alphabet. No number or letter can repeat more than two times (to make sure, any of letters or numbers can be used 2 times). How many such passwords do exist?
My solution is:
36 x 36 x 35 x 35 x 34 x 34 x 33 x 33
= 1.998.604.238.400  Password exist
Do i missing something?
 A: This is not correct.  The first two $36$s say you are allowed any character in the first two slots.  The first $35$ says you have used up one character, which only happens if the first two slots are the same.  This keeps going.  
You need to use an inclusion-exclusion argument.  If we ignore the restriction there are $36^8$ passwords.  Now we subtract the ones that have three or more of the same character.  For exactly three of one character, there are $36$ characters to have three of, $\binom{8}{3}$ ways to choose the three slots, and $35^5$ ways to fill the other slots.  You can follow this logic for four through eight of one character.  Unfortunately, we have subtracted $AAABBBCD$ twice, once because of the $A$s and once because of the $B$s, so you need to add back in all the combinations that have three or more of two different characters.  
Another approach, perhaps simpler this time, is to specifically account for the number of matches.  There are $36\cdot 35 \ldots 29$ passwords with distinct characters.  Now add the ones with one pair, two pairs, etc.  For two pairs you have $36 \choose 2$ to choose the paired characters, $8 \choose 2$ ways to place the lower paired characters, $6 \choose 2$ ways to place the higher pair, and $34\cdot 33\cdot 32\cdot 31$ ways to fill the rest.
