# How many four digit integer number exist that that the digits are either NOT in decreasing order or NOT in increasing order?(check my solution)

Here is a part two of a question, which is homework and I want to make sure of my answer:

B)How many four digit integer number exist that that the digits are either Non-decreasing (like 1347,1226,7778) or Non-increasing order (like 6421,6622,9888) ?

My solution for Non-decreasing part : The digits can be repeated so we can construct a four digit number with 4 or 3 or 2 or even one number . By picking 4 numbers out of 9 ( except 0 , because logically it cannot be anywhere in that four digit) there is only one arrangement that matches the property (like 1234)by picking 3 numbers out of 9 there is three arrangements(like 1233,1223,1123) by picking 2.....by picking 1.... So the answer would be like : $$1{9\choose 4}+ 3{9\choose 3}+ 1{9\choose 2}+ 1{9\choose 1}$$

For the Non-increasing part its the same except 0 can be involved as one last or two last or three last ones. So we have : $${9\choose 3}+ {9\choose 2}+ {9\choose 1}$$ So the final answer for the increasing part would be :

$$1{9\choose 4}+ 4{9\choose 3}+ 2{9\choose 2}+ 2{9\choose 1}$$

THE FINAL ANSWER FOR PART B is sum of this two answers and because of the OR in the question we have to reduce the common answers in our final answer because we count it twice . The common answers are 1111,222,...,9999 So the final answer is :

$$2{9\choose 4}+ 7{9\choose 3}+ 3{9\choose 2}+ 3{9\choose 1} -9$$

Am I missing somthing or doing something wrong ? I would really appreciate someone check my answer. Thanks in advance.

• Total minus increasing minus decreasing plus constant? Jun 23, 2020 at 13:49
• Also, your calculation is wrong. You have only chosen the digits, they must be arranged as well. Jun 23, 2020 at 13:54
• @user675453 if i want to construct a four digit number with any four integer(like 1,2,3,4) there is 4! Possibilities but only one of them is in increasing oder (1234) Jun 23, 2020 at 13:57
• See the case with 2 digits, these are possible combinations, $(3,1), (2,2) , (1,3)$ here number in ordered pair represents number of times a digit is repeated. Jun 23, 2020 at 13:59
• @user675453 i think you are misunderstanding what the question mean by “Not increasing” and “Not decreasing “ . Numbers like 3294 are not accepted and if we do what you said in the first comment they would be counted.please read the examples of those parts again . Jun 23, 2020 at 16:26

Let find a correct solution and compare with your numbers.

Obviously a quadruple of numbers can be brought in non-increasing (non-deacreasing) order in a unique way. Therefore it is required only to know how many copies of every digit are present. Essentially it is equivalent to problem of distributing 4 balls among 9 (or 10) bins and can be easily solved by stars and bars method.

If the sequence is non-decreasing it - as you have correctly noted - cannot contain $$0$$. This means we have choice between $$9$$ digits, so that the overall count is $$\binom{4+9-1}4=\binom{12}4=495 (\color{red}{\ne423}).\tag1$$
If the sequence is non-increasing it can contain up to three $$0$$. Thus we have choice between $$10$$ digits, one choice ($$0000$$) being invalid, so that the count is: $$\binom{13}4-1=714(\color{red}{\ne552}).\tag2$$

Together it gives (here you correctly defined the intersection of both sets): $$\binom{12}4+\binom{13}4-10=1200.$$

As seen from (1) and (2) your expressions heavily underestimate the actual numbers.

• Thank you so much . I really appreciate you help . Jun 24, 2020 at 5:48
• You are welcome. Let me know if you need help in finding the error in your calculations.
– user
Jun 24, 2020 at 5:51
• I tried to find my error , then I realized in non-increasing part i made a mistake about calculating 0s being involved. My new answer to that part is 219(in a logical way) . When I add 219 (0 being involved ) to 0 not being involved which is 423 as you mentioned , it is equal to 642. And 642 is 72 units less than the correct answer 714 . Also 423 is 72 units less than 495. So my conclusion is that I’m doing the 0 being involved part correct but I’m missing somthing about 0 not being involved in non-increasing part . Jun 24, 2020 at 6:57
• and ${\binom 9 2}=72$ so i think I’m missing somthing in calculating possible ways of constructing a four digit number with 2 integers (when 0 is not invloved). Jun 24, 2020 at 7:00
• You are correct. The error is there. The factor should be 3 instead of 1.
– user
Jun 24, 2020 at 7:04