0

I am sure there is a general and simplified way to solve this problem, I am just unable to figure out the generalized formula (if there is one).

Say we have to write a code with 4 digits, the digits can range from 0 to 9.

All digits in the code must be unique.
All of the digits cannot be neither increasing nor decreasing.

For example, "1234" is not allowed, neither is "1289" nor "9821".

How many code combinations are there in total?

2 Answers2

4

The total number of combinations is $\binom{10}{4}$.

For each combination there are $4!$ different arrangements.

Exactly $1$ of these arrangements is strictly increasing.

Exactly $1$ of these arrangements is strictly decreasing.

Hence the number of valid arrangements is $\binom{10}{4}\cdot(4!-1-1)$.

barak manos
  • 43,109
  • @amWhy: Not sure I understand your reasoning. First I choose $4$ distinct digits. For each choice, I have $24$ arrangements, and since the digits are distinct, there are only $2$ strict-direction arrangements. – barak manos Nov 28 '16 at 16:56
  • @amWhy: If you are unable to explain your reasoning, then I'd appreciate it if you could revoke your down-vote. – barak manos Nov 28 '16 at 17:01
  • Yes, I think you've got it; I was coming at it from a different direction! – amWhy Nov 28 '16 at 17:02
  • Barak But I did not downvote your answer! Though I can upvote it. – amWhy Nov 28 '16 at 17:03
  • @amWhy: Oh, OK... Well, somebody did at around the same time you posted your comment, so I figured that it was you... Thanks. – barak manos Nov 28 '16 at 17:03
  • @barakmanos Sorry I have done the downvote. Please make a small edit. – callculus42 Nov 28 '16 at 17:03
  • @callculus: Done, but why did you down-vote? – barak manos Nov 28 '16 at 17:04
  • @barakmanos I thought you didn´t catch all combinations. But now it looks right to me. – callculus42 Nov 28 '16 at 17:07
  • @callculus: OK, but could you please (please) next time, post a comment explaining why. It is rather annoying to get unexplained down-votes, in particularly when you're pretty sure that you've answered everything correctly. And even if you've made a mistake which justifies the down-vote, you cannot be aware of your mistake and learn from it when no explanation is provided. Personally, I always opt for a comment rather than a down-vote (i.e., only comment, no down-vote). That's your choice of course, but down-voting without any explanation is a kinda trolling IMO. – barak manos Nov 28 '16 at 17:13
  • @barakmanos You´re are right. I was formulating a comment but then I wasn´t sure anymore. But as you have seen I posted a comment to inform you that I was the downvoter. That was the best I could do after my mistake. After your edit I changed my downvote into an upvote. My intention was not to downvote and run away. I had your answer always in focus. – callculus42 Nov 28 '16 at 17:29
  • @callculus: cool, thanks :) – barak manos Nov 28 '16 at 17:32
0

Hint. Once you choose $4$ distinct digits in $\{0,1,\dots,9\}$ (you can do it in $\binom{10}{4}$ ways) in how many ways can you arrange them in decreasing order? How many in increasing order? Now take them away from the $4!$ possible permutations.

Robert Z
  • 145,942