[Math] How many arrangements of a bookshelf exist where certain books must be to the left/right of other books

discrete mathematicspermutations

The question at length is exactly this:

There are five distinct computer science books, three distinct
mathematics books, and two distinct art books. In how many ways can
these books be arranged on a shelf if one of the mathematics books is
on the left of all computer science book, and another mathematics book
is on the right of all the computer science books?

I have searched a ton online for a question that's even similar to this but have yet to find one. Most examples have set groupings of books to create an 'object' but none have the kind of modular specifications of this question.

I realize that there is ambiguity about if the math books are directly flush with the computer science books, or if they can be 'anywhere to the left/right' of the computer science books. I've attempted this question under the more challenging assumption and have gotten an answer as follows:

There are 4 different placements of two math books that will allow for the computer science books to be completely between the two.

1) 8 spaces between the two math books M__________M (1 way)

2) 7 spaces between the two math books: M_______M_ and _M_______M (2 ways)

3) 6 spaces: M______M__, _M______M_, __M______M (3 ways)

4) 5 spaces: M_____M___, _M_____M__, __M_____M_, ___M_____M. (4 ways)

Then I wanted to find the permutations of each of the ways above by the Rule of Product, and add them together by the Rule of Sum to get my final answer.

(1) 8 spaces: P(3, 2) * P(8, 8)

[Delimiting math books] * [permutations in between]

(2) 7 spaces: P (3, 2) * P(3, 1) * P(7, 7) * 2

[Delimiting math books] * [Options for book outside of delimitation] * [Permutations in-between] * [number of ways to achieve 7 spaces]

(3) 6 spaces: P (3, 2) * P(3, 2) * P(6, 5) * 3

[Delimiting math books] * [options for 2 books outside delimitation] * [permutation in-between] * [number of ways to achieve 6 spaces]

(4) 5 Spaces: P (3, 2) * P(3,3) * P(5, 5) * 4

[Delimiting math books] * [options for 3 books outside delimitation] * [permutation in-between] * [number of ways to achieve 5 spaces]

Then my final answer would be (1) + (2) + (3) + (4). My worry is that I'm missing some duplicates somehow.

Also conveniently, I believe the total for 5 spaces would satisfy the simpler question if it is actually referring to permutations with the chunk MCCCCCM.

Thanks in advance! I'd love to see specifically what I'm doing wrong (if I am indeed wrong).

Best Answer

Here is an approach that avoids using cases.

Set aside the art books for the moment. We will place them later.

We have to arrange the five distinct computer science books and three distinct mathematics books so that there is at least one mathematics book to the left of all the computer science books and at least one mathematics book to the right of all the computer science books. We have three choices for which mathematics book will be placed on the left end of the row and two choices for which mathematics book will be placed on the right end of the row. We now have six books (five computer science books and the remaining mathematics book) to arrange between the mathematics books we have placed at the ends of the row. We can arrange these six books in $6!$ ways. Hence, there are $3 \cdot 2 \cdot 6!$ ways of arranging the mathematics and computer science books.

We now have nine spaces (seven spaces between the eight books we have already placed and the two ends of the row) in which to place the first art book. Once it is placed, we have ten spaces (eight spaces between the nine books we have already placed and the two ends of the row) in which to place the second art book. Hence, we can arrange five distinct computer science books, three distinct mathematics books, and two distinct art books so that at least one mathematics book is to the left of all the computer science books and at least one mathematics book is to the right of all the computer science books in $$3 \cdot 2 \cdot 6! \cdot 9 \cdot 10$$ ways.