For finite sets , the inclusion-exclusion principle statesTo prove it, consider an element belonging to exactly of the sets. If , it contributes zero to both sides. If , its contribution on the right iswhich is its contribution to the union. Summing these contributions proves the formula.
For the keypad, a first digit zero cannot be entered. Define four families of valid codes: consists of all codes with no zero; consists of codes beginning with ; consists of with ; and consists of with . They cover every valid code. Indeed, if the first digit is not , a zero in the second position is impossible; a zero in the third requires the prefix ; a zero in the fourth requires the middle pair . In the third-position case the last digit cannot also be zero. Hence the only remaining zero-containing possibilities are exactly and .
Their cardinalities areThe only nonempty pairwise intersections are , with codes, and , with one code. All triple and fourfold intersections are empty. Applying inclusion-exclusion therefore givesThe restriction concerns actual preceding keypresses. It cannot license two successive zeros unless the first-key condition is already satisfied.
Articles by others on the same topic
There are currently no matching articles.