## Task A-4.5.

How many nine-digit numbers are there whose digits are $1,2,3,4,5,6,7,8$ and 9, and no three consecutive digits are 123, 246, or 678?
## Solution.

There are 9! nine-digit numbers that have digits from 1 to 9. From this number, we must subtract the number of numbers that have three consecutive digits 123, 246, or 678.

The number of numbers that have consecutive digits 123 is 7! (we permute that block and the remaining 6 digits).

Similarly, the number of numbers that contain 246 is 7!, and the number of numbers that contain 678 is 7!.

Note that the solution is not 9! - 3 * 7! because we have subtracted multiple times the numbers that contain both 123 and 678, as well as those that contain both 246 and 678.

There is no number that has both 123 and 246 as consecutive digits.

1 point

The number of numbers that contain both 123 and 678 is 5!, 1 point

and those that contain both 246 and 678, i.e., 24678, is also 5!.

1 point

The final solution is 9! - 3 * 7! + 2 * 5!.

1 point

Note: The principle we used is called the inclusion-exclusion principle, but it is not necessary to mention it. The final solution is 9! - 3 * 7! + 2 * 5! = 348000.

Note: A student who claims the result is 9! - 3 * 7! should receive 2 points.