Weekend combinatorics (II)

25 Nov, 2022 at 13:31 | Posted in Varia | 7 Comments

How many permutations exist of the ten digits (0-9) that either begin with”123″, contain “56” in the 6th & 7th positions, or end with “789”?

1. A + B + C – AnB – AnC – BnC – 2*AnBnC
= 7! + 8! + 7! – 5! – 4! – 5! – 2*2!
= 49932

• Almost, but not quite. If you do the arithmetic right and think again about the last part (-2*AnBnC) you will get the right answer — 50138 đź™‚

• A + B + C â€“ AnB â€“ AnC â€“ BnC + AnBnC
= 7! + 8! + 7! â€“ 5! â€“ 4! â€“ 5! + 2!
= 50138

• Spot on đź™‚

• How long would it take you to actually generate them, compared to my program?

• I guess something like 10 times more (at least if we include some of the programming time) đź™‚
But I still think it’s nice to know that you can sit down with just a pencil and paper and solve things …

2. Assuming no repetitions and “1234056789” is counted only once, 50138?
.
https://subbot.org/misc/perms.rb.txt

Sorry, the comment form is closed at this time.