1

I have an exercise divided in two parts:

a.) How many ( $x \in \mathbb{Z}$ ), with ($ 104050607080 \leq x \leq 908070605040$ ), can be formed using the digits of ( $106506506503$ ), such that ( $x$ ) is divisible by $20$ and contains the string "$036$" as a substring?

b.) How many solutions are there to the equation ( $x_1 + x_2 + x_3 + x_4 + x_5 + x_6 + x_7 + x_8 = 8004$ ), where ( $x_1, \ldots, x_8 \in \mathbb{Z}$ ) and ( $x_1, \ldots, x_8 \geq 0$ ), with the following constraints:

  • ( $x_1 \geq 49$ ),
  • ( $300 \leq x_3 \leq 399$ ),
  • ( $550 \leq x_5 \leq 749$ ),
  • ( $x_6 \geq 4$ ),
  • ( $x_1 + x_7 + x_8 = 350$ ),
  • ( $2x_1 + x_3 + x_5 \geq 950$ )?

Since I have no idea on where to start (except doing some case work for the specified constraints) I would ask if there is someone kind me enough to show me how to solve this kind of exercise. For part b. I think it's more straightforward. I would need to find all the possible values for each $x_1...x_8$ that satisfy the constraints and then multiply the number of possible choices for each $x$. Is that correct?

Edit:

  • Please note that substring can only appear once.
  • Please note that the leftmost digit of any positive integer is not permitted to equal 0.
  • Please also note that I am not allowed to use computational tools otherwise I would have solved this exercise in C++. For instance, for part b I have been suggested to use inclusion-exclusion along with stars and bars.

I am doing, very slowly though, some progress on part b of the exercise. This is what I've done so far by following the example of another exercise solution:

Step 1: Transform the Variables

Transform the variables to eliminate the minimum bounds:

  • Let $~ y_1 = x_1 - 49 $
  • Let $~ y_3 = x_3 - 300 $
  • Let $~ y_5 = x_5 - 550 $
  • Let $~ y_6 = x_6 - 4 $

This transforms the equation to: $$ (y_1 + 49) + x_2 + (y_3 + 300) + x_4 + (y_5 + 550) + (y_6 + 4) + x_7 + x_8 = 8004 $$

Simplifying, we get: $$ y_1 + x_2 + y_3 + x_4 + y_5 + y_6 + x_7 + x_8 = 7101 $$

Step 2: Count Solutions without Constraints

The number of (non-negative integer) solutions to $~ y_1 + x_2 + y_3 + x_4 + y_5 + y_6 + x_7 + x_8 = 7101 $ is: $$ \binom{7101 + 7}{7} = \binom{7108}{7} $$

Step 3: Apply Constraints Using Inclusion-Exclusion

Constraint: $ ~x_1 + x_7 + x_8 = 350 $

The transformed constraint is: $$ y_1 + 49 + x_7 + x_8 = 350 $$ $$ y_1 + x_7 + x_8 = 301 $$ The number of solutions is: $$ \binom{301 + 2}{2} = \binom{303}{2} $$

Constraint: $~ 300 \leq x_3 \leq 399 $

The transformed constraint is: $$ 0 \leq y_3 \leq 99 $$

Constraint: $~ 550 \leq x_5 \leq 749 $

The transformed constraint is: $$ 0 \leq y_5 \leq 199 $$

Constraint: $~ x_6 \geq 4 $

The transformed constraint is: $$ y_6 \geq 0 $$

Constraint: $~ 2x_1 + x_3 + x_5 \geq 950 $

The transformed constraint is: $$ 2(y_1 + 49) + (y_3 + 300) + (y_5 + 550) \geq 950 $$ $$ 2y_1 + y_3 + y_5 \geq 2 $$

Inclusion-Exclusion Principle

We need to count the number of solutions to:
$$ y_1 + x_2 + y_3 + x_4 + y_5 + y_6 + x_7 + x_8 = 7101 $$ that satisfy the constraints using inclusion-exclusion.

  1. Initial Count: $$ \binom{7108}{7} $$

  2. Subtract invalid solutions where constraints are not met:

Constraint 1: $$ y_1 + x_7 + x_8 = 301 $$

The number of solutions is:
$$ \binom{303}{2} $$

Constraint 2: $~ 0 \leq y_3 \leq 99 $

For $~ y_3 $: $$ \sum_{k=0}^{99} \binom{7101 - k + 6}{6} $$

Constraint 3: $~ 0 \leq y_5 \leq 199 $

For $~ y_5 $: $$ \sum_{k=0}^{199} \binom{7101 - k + 6}{6} $$

Combined Constraint: $~ 2y_1 + y_3 + y_5 \geq 2 $

We use inclusion-exclusion to count solutions satisfying $~ 2y_1 + y_3 + y_5 \geq 2 $:

$$ \sum_{k=0}^{99} \sum_{j=0}^{199} \binom{7101 - k - j + 5}{5} $$

So, the inclusion-exclusion principle gives us: $$ N = \binom{7108}{7} - \sum_{k=0}^{99} \binom{7101 - k + 6}{6} - \sum_{k=0}^{199} \binom{7101 - k + 6}{6} + \sum_{k=0}^{99} \sum_{j=0}^{199} \binom{7101 - k - j + 5}{5} $$

user2661923
  • 42,303
  • 3
  • 21
  • 46
zaxunobi
  • 217
  • For what it's worth, virtually every MathSE posted question that I have seen, that followed this article on MathSE protocol has been upvoted rather than downvoted. I am not necessarily advocating this protocol. Instead, I am merely stating a fact: if you scrupulously follow the linked article, skipping/omitting nothing, you virtually guarantee a positive response. – user2661923 Jul 23 '24 at 09:38
  • @user2661923 thanks for your suggestions, I will take my time to read everything. Correct, without replacement. Honestly, I am not sure if are we to assume that the leftmost digit of any positive integer is not permitted to equal 0, but I would say that most likely that is the case.

    May I ask you why you haven't posted a reply and posted instead multiple comments? Would I be asking too much for a reply with a step-by-step solution?

    – zaxunobi Jul 25 '24 at 15:24
  • @user2661923 I've updated my question – zaxunobi Jul 27 '24 at 05:22
  • I have edited your question to compensate for your use of \[...\] and \(...\), which works in latex but does not work in mathjax. I will soon post a complete answer to both questions. – user2661923 Jul 27 '24 at 16:20

1 Answers1

1

This answer will use both Inclusion-Exclusion and Stars and Bars. See this article for an introduction to Inclusion-Exclusion. Then, see this answer for an explanation of and justification for the Inclusion-Exclusion formula.

For Stars and Bars theory, see this article and this article.

$\underline{\text{Part a}}$

How many $~x \in \mathbb{Z}~$, with $~104050607080 \leq x \leq 908070605040,~$ can be formed using the digits of $~106506506503,~$ such that $~x~$ is divisible by $~20~$ and contains the string "$036$" as a substring?

Let the multiset $~A~$ denote $~\{0,0,0,0,1,3,5,5,5,6,6,6\}.~$ Since the lower and upper bounds for $~x~$ are each $~12~$ digit numbers, and $~A~$ contains exactly $~12~$ elements, when constructing $~x,~$ each element in $~A~$ must be used exactly once.

With respect to the constraints:

  • The upper bound can be ignored, because $~A~$ does not contain a $~9.$
  • The lower bound will be violated if and only if $~x~$ begins either "0", or "100" or "103".
  • Since $~A~$ contains only one $~3,~$ the "036" string can only occur once. Reading the digit positions from left to right, the "036" string must start in one of the digit positions $~1~$ through $~10~$ inclusive.
  • The divisibility by $~20,~$ constraint will be violated if and only if $~x~$ does not end in either "00" or "60".

Using Inclusion-Exclusion, let the set $~S~$ denote the set of all $~12~$ digit numbers constructed from the set $~A,~$ that contain the string "036". Let $~S_1~$ denote the subset of $~S~$ where the lower bound is violated. Let $~S_2~$ denote the subset of $~S~$ where the divisibility by $~20~$ is violated.

Then, the desired computation is

$$|~S~| - |S_1 \cup S_2| \\ = | ~S~| - |~S_1~| - |~S_2~| + |~ S_1 \cap S_2~|.\tag1 $$


$\underline{\text{Computation of} ~| ~S ~|}$

The "036" can occur in any of $~10~$ positions. For each such position, the remaining elements of $~\{0,0,0,1,5,5,5,6,6\}~$ need to be distributed among the $~9~$ remaining positions. Therefore,

$$| ~S~| = 10 \times \frac{9!}{3! ~3! ~2!} = 50400.$$


$\underline{\text{Computation of} ~| ~S_1 ~|}$

There are $~5~$ separate cases to consider.

  • The number begins "036".
    The computation is $~\displaystyle \frac{9!}{3! ~3! ~2!} = 5040.$

  • The number begins "0", with the "036" string occurring in one of positions 2 through 10 inclusive.
    The computation is $~\displaystyle 9 \times \frac{8!}{3! ~2! ~2!} = 15120.$

  • The number begins "1036".
    The computation is $~\displaystyle \frac{8!}{3! ~3! ~2!} = 560.$

  • The number begins "10036".
    The computation is $~\displaystyle \frac{7!}{3! ~2! ~2!} = 210.$

  • The number begins "100", with the "036" string occurring in one of positions 4 through 10 inclusive.
    The computation is $~\displaystyle 7 \times \frac{6!}{3! ~2!} = 420.$

Therefore,

$$|~S_1~| = 5040 + 15120 + 560 + 210 + 420 = 21350.$$


$\underline{\text{Computation of} ~| ~S_2 ~|}$

There are $~3~$ separate cases to consider.

  • The number ends "036".
    The computation is $~\displaystyle \frac{9!}{3! ~3! ~2!} = 5040.$

  • The number has "036" in position 9, but does not end in "0".
    The computation is $~\displaystyle \frac{9!}{3! ~3! ~2!} - \frac{8!}{3! ~2! ~2!} = 3360.$

  • The number has "036" in one of positions 1 thru 8 inclusive, but does not end in either "60" or "00".
    The computation is
    $~\displaystyle 8 \times \left[ ~\frac{9!}{3! ~3! ~2!} - \frac{7!}{3! ~2!} - \frac{7!}{3! ~2!} ~\right] = 33600.$

Therefore,

$$|~S_2~| = 5040 + 3360 + 33600 = 42000.$$


$\underline{\text{Computation of} ~| ~S_1 \cap S_2 ~|}$

There are $~9~$ cases to consider.

  • The number begins "036" but does not end in either "00" or "60".
    The computation is $~\displaystyle \frac{9!}{3! ~3! ~2!} - \frac{7!}{3! ~2!} - \frac{7!}{3! ~2!} = 4200.$

  • The number begins "0" and ends in "036".
    The computation is $~\displaystyle \frac{8!}{3! ~2! ~2!} = 1680.$

  • The number begins "0", has "036" starting in position 9, but does not end in "0".
    The computation is $~\displaystyle \frac{8!}{3! ~2! ~2!} - \frac{7!}{3! ~2!} = 1260.$

  • The number begins "0", has "036" starting in one of positions 2 through 8, but does not end in either "00" or "60".
    The computation is
    $\displaystyle 7 \times \left[ ~\frac{8!}{3! ~2! ~2!} - \frac{6!}{3! ~2!} - \frac{6!}{3!}~\right] = 10500.$

  • The number begins "1036" but does not end in either "00" or "60".
    The computation is $~\displaystyle \frac{8!}{3! ~3! ~2!} - \frac{6!}{3! ~2!} - \frac{6!}{3! ~2!} = 440.$

  • The number begins "10036" but does not end in either "00" or "60".
    The computation is $~\displaystyle \frac{7!}{3! ~2! ~2!} - \frac{5!}{3! ~2!} - \frac{5!}{3!} = 180.$

  • The number begins "100" and ends in "036".
    The computation is $~\displaystyle \frac{6!}{3! ~2!} = 60.$

  • The number begins "100", has "036" starting in position 9, but does not end in "0".
    The computation is $~\displaystyle \frac{6!}{3! ~2!} - \frac{5!}{3! ~2!} = 50.$

  • The number begins "100", has "036" starting in one of positions 4 through 8, but does not end in "60".
    The computation is
    $\displaystyle 5 \times \left[ ~\frac{6!}{3! ~2!} - \frac{4!}{3!}~\right] = 280.$

Therefore,

$$|~S_1 \cap S_2 ~| \\= 4200 + 1680 + 1260 + 10500 + 440 + 180 + 60 + 50 + 280 \\= 18650.$$


$\underline{\text{Final Computation}}$

$$| ~S~| - |~S_1~| - |~S_2~| + |~ S_1 \cap S_2 ~| \\= 50400 - [21350 + 42000] + 18650 = 5700.$$




$\underline{\text{Part b}}$

b.) How many solutions are there to the equation ( $x_1 + x_2 + x_3 + x_4 + x_5 + x_6 + x_7 + x_8 = 8004$ ), where ( $x_1, \ldots, x_8 \in \mathbb{Z}$ ) and ( $x_1, \ldots, x_8 \geq 0$ ), with the following constraints:

  • ( $x_1 \geq 49$ ),
  • ( $300 \leq x_3 \leq 399$ ),
  • ( $550 \leq x_5 \leq 749$ ),
  • ( $x_6 \geq 4$ ),
  • ( $x_1 + x_7 + x_8 = 350$ ),
  • ( $2x_1 + x_3 + x_5 \geq 950$ )?

The first portion of your analysis for part (b) looks good. However, I would organize things differently.

Set

  • $y_1 = x_1 - 49 \implies 0 \leq y_1.$
  • $y_3 = x_3 - 300 \implies 0 \leq y_3 \leq 99.$
  • $y_5 = x_5 - 550 \implies 0 \leq y_5 \leq 199.$
  • $y_6 = x_6 - 4 \implies 0 \leq y_6.$
  • For $~i \in \{2,4,7,8\}, ~$ set $~y_i = x_i.~$

So, at this point, you are working exclusively in the variables $~y_1, \cdots, y_8,~$ where all of these variables are integers with a lower bound of $~0,~$ and only the variables $~y_3~$ and $~y_5~$ have an upper bound.

Then, the constraints to be satisfied are

  • Constraint 1: $~y_1 + \cdots + y_8 = 8004 - 903 = 7101.$
  • Constraint 2: $~y_1 + y_7 + y_8 = 350 - 49 = 301.$
  • Constraint 3: $~2y_1 + y_3 + y_5 \geq 950 - [98 + 300 + 550] = 2.$

At this point, it is time to come up with a strategy.

Since the minimum value of $~2y_1 + y_3 + y_5~$ is $~0,~$ the number of ordered triples $~(y_1, y_3, y_5)~$ that are in violation can be individually scrutinized.

Further, Based on Constraint 2, Constraint 1 can be re-expressed as

  • Constraint 4: $~y_2 + \cdots + y_6 = 7101 - 301 = 6800.$

Further, Constraint 4 and Constraint 2 share no variables. Therefore, if you temporarily ignore Constraint 3, the number of satisfying solutions to Constraint 4 and Constraint 2 are

$$\text{[Number of solutions to Constraint 4}] \\\times [\text{Number of solutions to Constraint 2}]. $$

So, my overall approach to part b will be to temporarily ignore Constraint 3, compute the corresponding product, and then deduct the number of solutions where Constraint 3 is violated. When needed, I will follow the model in this answer.


$\underline{\text{Number of solutions to Constraint 2}}$

Constraint 2 is

  • $y_1 + y_7 + y_8 =301.$
  • $y_1, y_7, y_8 \in \Bbb{Z_{\geq 0}}.$

The number of solutions is

$$\binom{303}{2}.$$


$\underline{\text{Number of solutions to Constraint 4}}$

Constraint 4, with the upper bounds included is

  • $y_2 + \cdots + y_6 = 6800.$
  • $y_2, \cdots, y_6 \in \Bbb{Z_{\geq 0}}.$
  • $y_3 \leq 99.$
  • $y_5 \leq 199.$

Let :

  • $~S~$ denote the set of all solutions to the above problem, where the upper bound constraints on $~y_3~$ and $~y_5~$ are ignored.
  • $~S_1~$ denote the subset of $~S~$ where $~y_3 \geq 100.$
  • $~S_2~$ denote the subset of $~S~$ where $~y_5 \geq 200.$

Then, the desired computation is

$$| ~S ~| - | ~S_1~| - | ~S_2 ~| + | ~S_1 \cap S_2 ~|.$$

Following the linked model, the computation is

$$\binom{6804}{4} - \binom{6704}{4} - \binom{6604}{4} + \binom{6504}{4}.$$


$\underline{\text{Number of combined solutions to Constraints 2 and 4}}$

The computation is

$$\binom{303}{2}$$

$$\times \left[ ~\binom{6804}{4} - \binom{6704}{4} - \binom{6604}{4} + \binom{6504}{4} ~\right].$$


$\underline{\text{Individual} ~y_1, y_3, y_5 ~\text{Violations}}$

The constraint to be violated is

$$2y_1 + y_3 + y_5 \geq 2.$$

Since $~y_1, y_3, y_5~$ must each be non-negative integers, the following is the complete set of ordered triplets $~(y_1, y_3, y_5)~$ that are in violation:

$$\{ ~(0, 0, 0), ~(0,0,1), ~(0,1,0) ~\}.$$

So, you simply repeat all of the analysis so far, three times. once for each of the possible $~(y_1, y_3, y_5)~$ violations. You obtain three products, sum them, and then deduct that from the product already computed.


$\underline{\text{Number of Violation Solutions to Constraint 2}}$

Here, $~y_1~$ is set to $~0.~$ So, the number of violation solutions to Constraint 2 is

$$\binom{302}{1}.$$


$\underline{\text{Number of Violation Solutions to Constraint 4}}$

With $~y_3, y_5~$ each fixed at either $~0~$ or $~1,~$ you will have (in effect) three variables, instead of $~5.~$ Further, the sums of the three violation constraints will either be $~6800, 6799,~$ or $~6799.$

Therefore, the number of violation solutions to Constraint 4 is

$$\binom{6802}{2} + \left[ ~2 \times \binom{6801}{2} ~\right].$$


$~\underline{\text{Total Number of Violation Solutions}}$

$$\binom{302}{1} \times \left\{ ~\binom{6802}{2} + \left[ ~2 \times \binom{6801}{2} ~\right] ~\right\}.$$


$~\underline{\text{Final Computation.}}$

Set

$$B = \binom{303}{2}$$

$$\times \left[ ~\binom{6804}{4} - \binom{6704}{4} - \binom{6604}{4} + \binom{6504}{4} ~\right].$$

Set

$$C = \binom{302}{1}\times \left\{ ~\binom{6802}{2} + \left[ ~2 \times \binom{6801}{2} ~\right] ~\right\}.$$

Then, the final computation is

$$B - C.$$

user2661923
  • 42,303
  • 3
  • 21
  • 46
  • Thanks! So whenever a bound contains a digit that is not present in the set, I can totally disregard that bound? – zaxunobi Aug 02 '24 at 17:40
  • @zaxunobi I don't understand your last comment/question. First of all, are you asking about part a or part b? Second of all, please re-phrase your question to try to make it crystal clear what you are asking. If possible, please include an illustrative example, in your comment/question, for clarity. – user2661923 Aug 02 '24 at 19:08
  • Sorry! I am asking about part a. Take for example that x >= 2020202020202 and x <= 9876543210987 Set of possible digits is 2723030903032. Since the set is missing the digit "8" I can totally disregard checking the upper bound when evaluating all the cases (S, S1, S2...). – zaxunobi Aug 03 '24 at 05:37
  • @zaxunobi Yes, that's exactly right. – user2661923 Aug 03 '24 at 05:49
  • One more question. In the part a, computation of S2, you wrote "The number has "036" in one of positions 1 thru 8 inclusive, but does not end in either "60" or "00"." Shouldn't be in one of positions 2 thru 8 inclusive? Since the first digit can never be zero. Since we're looking for string that violates only the divisibility in S2. Otherwise it would make sense. – zaxunobi Aug 03 '24 at 09:05
  • @zaxunobi No. This is a subtle point. I treat the condition of "leftmost digit starts with 0" as merely one type of lower bound violation. Therefore, it must be included in $~S_2~$ as well as being included in $~S_1 \cap S_2.~$ Note how this approach dovetails with the formula $$| ~S~| - |~S_1~| - |~S_2~| + |~ S_1 \cap S_2~|.$$ – user2661923 Aug 03 '24 at 16:57
  • Thanks again! Would I be asking too much if you could be able to revise an exercise I solved very similar to the one posted? In case I should post a new question? – zaxunobi Aug 04 '24 at 04:58
  • @zaxunobi Post the new question. In order for me to have permission to answer the question, you should follow this article on MathSE protocol. If you scrupulously follow the linked article, skipping/omitting nothing, you guarantee that MathSE protocol has been met. Leave another comment, following this answer, with a link to the new question, once it is posted. – user2661923 Aug 04 '24 at 05:22
  • Okay and should I post all the work I've done so that you can revise it or should I post just the part where I have concern? – zaxunobi Aug 04 '24 at 06:35
  • @zaxunobi Just follow the instructions in the protocol article. Then, someone will answer; if no one else does, and if I am qualified to answer, then I will. As to the extent that my answer, or someone else's answer revises the work in your new posted question, that is impossible to predict at this time. – user2661923 Aug 04 '24 at 07:32
  • Here's the link to the question: https://math.stackexchange.com/questions/4954479/revision-of-my-solution-and-help-regarding-combinatorial-exercise-with-constrain – zaxunobi Aug 04 '24 at 15:53
  • 1
    I think the Number of Violation Solutions to Constraint 2 is actually $ 3* \binom{302}{1}$. Am I correct? – zaxunobi Sep 14 '24 at 13:05
  • So, even though y1 (the only variable affecting the constraint) is always = 0 they need to be treated as 3 separate cases? – zaxunobi Sep 15 '24 at 04:16
  • 1
    @zaxunobi I changed my mind, and decided that my original answer is correct, and I have changed my answer back to what it as. Let me explain. You are trying to enumerate all the solutions to constraint-4 times all of the solutions to constraint-2, under the assumption that constraint-3 is violated. Constraint-3 can be violated in 3 different ways. One way involves $~\displaystyle \binom{302}{1} \times \binom{6802}{2}.~$ The other two violations each involve $~\displaystyle \binom{302}{1} \times \binom{6801}{2}.~$ My answer reflects this sum of these three products. – user2661923 Sep 15 '24 at 04:53
  • Thanks again for the clarification! I have a posted another question regarding part b of a problem (diophantine equation) if you want to check it out: https://math.stackexchange.com/questions/4971702/completing-the-solution-to-a-constrained-diophantine-equation-with-inequality-co – zaxunobi Sep 15 '24 at 06:13