Restricted line arrangements

Count lines of distinct objects with together, apart, position and order restrictions, then turn the counts into probabilities.

More
Reading settings

Read offline with Premium

Save lessons and figures on this device with Premium.

Connect at least once every 30 days to confirm Premium. Topic checks, coaching and sync need a connection.

On this page

Reading settings

Appearance and reading tools for your lessons.

Live preview

Take a moment to read at your own pace. Choose the font and spacing that feel comfortable for you.

Pause after each idea, then explain it in your own words before moving on.

Narrower lines take effect when the screen has room.

Colour theme
Reading font
Line spacing
Reading width
Section links
Worked examples

Open example banners when a lesson starts. Hints and solutions stay closed until you open them.

Checking Premium access…

Explore Premium
Revision Mode

Hide questions, activities and worked examples to read the notes. Turn off to show the full lesson.

Checking Premium access…

Explore Premium

Enlarged diagram

Arranging people or objects in a line becomes interesting when there are rules: two friends must sit together, two rivals must be apart, a particular person must take an end seat. This lesson starts from the unrestricted count n!, then handles each kind of rule with its own technique: glue objects into a block, place objects into the gaps between others, or fill restricted positions first. It ends by turning those counts into probabilities for a random arrangement.

Start from the unrestricted line

An arrangement in a line fills positions 1, 2, 3, … from left to right. With n distinct objects, the first position has n choices, the next n-1, and so on, so there are n! arrangements. Seven different people can stand in a queue in 7! = 5040 ways.

A restriction removes some of those orders. Before counting, decide which kind of restriction you have:

  • Together: specified objects must form one unbroken group.
  • Apart: specified objects must not stand next to each other.
  • Position: an object must, or must not, occupy a particular place such as an end.
  • Relative order: one object must come somewhere before another, not necessarily next to it.

Each kind has a natural method. Use the method that matches the wording; a calculation that answers a different restriction can look reasonable and still be wrong.

Glue objects that must be together

When k specified objects must be together, treat them as one block. The block and the other n-k objects make n-k + 1 units, giving (n-k + 1)! unit orders. The block’s own objects can then be ordered in k! ways. Multiply the two stages.

Worked example 1

Keep three maths books together

Seven different books, including three different maths books, are placed in a row on a shelf. In how many arrangements are the three maths books next to each other?

Show full solutionHide solution
  1. Count the units

    Method

    Replace the three maths books with one block.

    Reason

    Any order of the units keeps the maths books together.

    Working

    Answer

    The block and the four other books make 7-3 + 1 = 5 units. These have 5! = 120 orders.

  2. Order the books inside the block

    Method

    Arrange the three maths books within their block.

    Reason

    The maths books are different, so changing their order gives a different shelf.

    Working

    Answer

    N = 5! × 3!; = 120 × 6; = 720.
  3. Check the count with a fraction of all orders

    Method

    Compare the result with the unrestricted count.

    Reason

    A restricted count must be smaller, and its fraction should be reasonable.

    Working

    Answer

    There are 7! = 5040 shelves altogether, and 720/5040 = 1/7. Omitting the internal order would give 120 shelves, which counts each block order as a single shelf.

Practise

Check your understanding 1

Two friends in a queue of six

Six different people, including two friends, stand in a queue. The two friends must stand next to each other. Enter the number of units to arrange after you treat the friends as a block, then the number of possible queues.

Show answerHide answer
N = 5! × 2!; = 120 × 2; = 240.

Exactly two specified objects are apart in all the other queues: 6!-240 = 480. This complement works for a single pair because “not together” and “apart” mean the same thing for two objects.

Separate objects with gaps

For three or more objects, “no two of them together” and “not all of them together” are different restrictions. The first forbids every adjacent pair. The second only forbids the single block of all of them.

For “no two together”, place the other objects first. Their arrangement creates gaps: one before the first object, one between each neighbouring pair and one after the last. Put at most one restricted object in each gap. Then no two restricted objects can touch.

Worked example 2

Keep three children apart

Four different adults and three different children stand in a line. Find the number of lines in which no two children are next to each other. Compare it with the number of lines in which the three children are not all together.

Show full solutionHide solution
  1. Arrange the adults

    Method

    Place the unrestricted objects first.

    Reason

    Their positions define where the children can go.

    Working

    Answer

    The adults have 4! = 24 orders. Each order leaves five gaps, shown as squares:

    square A square A square A square A square
  2. Place the children in different gaps

    Method

    Choose an ordered set of three gaps.

    Reason

    Different children in the same chosen gaps make a different line, so order matters.

    Working

    Answer

    N = 4! × ⁵P₃; = 24 × 60; = 1440.

    Choosing gaps with (5 choose 3) = 10 and forgetting to arrange the children would give 24 × 10 = 240, which treats the children as identical.

  3. Answer the other restriction with a complement

    Method

    Remove the lines in which all three children form one block.

    Reason

    “Not all together” still allows two children to stand side by side.

    Working

    Answer

    All three together: 5! × 3! = 720. So

    M = 7!-720; = 5040-720; = 4320.

    The line C C A C A A A is counted in M but not in N, because two children are next to each other.

Check your understanding 2

Five boys and three girls in a row

Five different boys and three different girls sit in a row of eight seats. Find the number of arrangements in which no two girls sit next to each other. Then find the number in which the three girls are not all next to each other.

Show answerHide answer

The five boys have 5! = 120 orders and leave six gaps:

N = 5! × ⁶P₃; = 120 × 120; = 14400.

For the second restriction, remove the block of all three girls:

M = 8!-6! × 3!; = 40320-4320; = 36000.

Fill restricted positions first

When an object must occupy a named place, fill that place first and then arrange everything that remains. Two teachers and five students, all different, stand in a line of seven. If the teachers must stand at both ends, the ends have 2! orders and the middle five places have 5!:

N = 2! × 5!; = 2 × 120; = 240.

For “at least one end”, a direct count needs separate cases. The complement is often shorter: count the lines with no teacher at either end and subtract them from all lines.

A relative-order restriction is different again. In half of all arrangements A stands somewhere to the left of B, because swapping A and B pairs each such line with one where B is to the left of A. Five different people therefore have 5!/2 = 60 lines with A to the left of B. Adjacency is not required.

Check your understanding 3

A teacher at an end

The same two teachers and five students stand in a line of seven. Find the number of lines with a teacher at one or both ends. Use the complement, then check your answer by adding disjoint cases. Explain why 2 × 6! is not the answer.

Show answerHide answer

With no teacher at either end, the two ends are filled by students in ⁵P₂ = 20 ordered ways and the middle five places in 5! ways:

N = 7!-⁵P₂ × 5!; = 5040-2400; = 2640.

Case check: exactly one teacher at an end gives 2 × 2 × 5 × 5! = 2400 (choose the end, the teacher, the student at the other end, then the middle). Both ends gives 2! × 5! = 240. The total is 2400 + 240 = 2640.

The count 2 × 6! places a teacher at the left end and adds the lines with a teacher at the right end. Lines with teachers at both ends are counted twice, so it exceeds the answer by 240.

A random line turns counts into probabilities

If the objects are arranged at random, every one of the n! orders is equally likely. A probability is then the restricted count divided by n!:

P(event) = (number of arrangements in the event)/(n!).

For two specified people in a random line of n, the block method gives 2 × (n-1)! arrangements with them together, so

P(together) = (2 × (n-1)!)/(n!); = 2/n.

This only applies when every order is equally likely. A queue formed by people arriving in groups, for example, is not a random arrangement of individuals.

Common mistakes

  • Forgetting to multiply by the internal arrangements of a block.
  • Counting the gaps between k objects as k-1 when the ends are also available; there are k + 1 gaps in a line.
  • Filling unrestricted positions first and running out of valid choices for the restricted ones.
  • Subtracting “together” from the total to get “apart” when more than two objects must be separated.
  • Using a probability’s numerator and denominator from different counting conventions.

Before you move on

Try it yourself 1

A pair together and a third person away from the ends

Minimal support

Seven different people, including Ana, Ben and Chen, stand in a line in a random order.

  1. Find the number of lines in which Ana and Ben are next to each other and Chen is not at either end.
  2. Find the probability of that event.
  3. Given that Ana and Ben are next to each other, find the probability that Chen is not at either end.

Explain why Chen’s end positions can be counted as positions among the units after Ana and Ben are glued.

Write your answer, then compare it with the solution

Hint 1

Glue first, then place Chen

Treat Ana and Ben as one block. Chen is at an end of the line exactly when Chen is the first or last unit. Fill Chen’s place before arranging the other units.

Show full solutionHide solution
  1. Glue the pair

    Method

    Make Ana and Ben one block.

    Reason

    The together condition is satisfied by every order of the units.

    Working

    Answer

    The block and five other people make six units. Without the condition on Chen, there are 6! × 2! = 1440 lines with Ana and Ben together.

  2. Place Chen away from the ends

    Method

    Use the unit positions to describe the ends.

    Reason

    Chen occupies one seat, so Chen is at the left end exactly when Chen is the first unit, and at the right end when Chen is the last unit.

    Working

    Answer

    Chen has four interior unit positions out of six. The other five units then have 5! orders, and the block has 2! internal orders:

    N = 4 × 5! × 2!; = 4 × 120 × 2; = 960.

    Check with a complement: Chen first or last unit gives 2 × 5! × 2! = 480, and 1440-480 = 960.

  3. Turn the counts into probabilities

    Method

    Divide by the number of lines in the reference group.

    Reason

    The random line makes all 7! orders equally likely; a condition changes the reference group.

    Working

    Answer

    P(E) = 960/5040; = 4/21.

    Given Ana and Ben together, only the 1440 lines with the pair together remain equally likely:

    P(E ∣ T) = 960/1440; = 2/3.

    Equivalently, given the six units, Chen is equally likely to be any of the six units, and four of them are interior.

Questions

Open the discussion

Syllabus and review details

Last reviewed:

Back to top