201k views
0 votes
How many arrangements of the digits 1, 2, 3, ..., 9 have the property that every digit (except the first) is no more than 3 greater than the previous digit? (For example, the arrangement 214369578 has this property. However, 312548697 does not have the property since 8 occurs immediately after 4, and 8 > 4 + 3.)

User FloSchmo
by
8.1k points

1 Answer

6 votes

Final answer:

To calculate the number of arrangements that satisfy the given property, use a recursive approach to iterate through each digit and consider all possible valid previous digits.

Step-by-step explanation:

To calculate the number of arrangements that satisfy the given property, we can use a recursive approach. Let's consider each digit, starting from the second digit, and calculate the number of valid arrangements that end with that digit.

For each digit, we consider all possible valid previous digits (i.e., digits that are no more than 3 greater than the current digit). If we denote by arr[i] the number of valid arrangements ending with digit i, then we can calculate arr[i] by summing up all arr[j] where j is a valid previous digit.

We initialize arr[0] to 1, as there is only one valid arrangement that ends with the first digit. Then, we iterate through the digits from 2 to 9 and calculate arr[i] by summing up all arr[j] where j satisfies the property mentioned above. Finally, we sum up all the values in arr[] to get the total number of arrangements that satisfy the given property.

User Havnar
by
7.7k points

No related questions found