Your country

Tools that support it use your country for local currency, number formats, units and paper size. Your choice is saved only in this browser.

Type a name or a two-letter code. Use the up and down arrow keys to move through the countries, Enter to choose one and Escape to close.

Placement Aptitude (Quant, Logical, Verbal)  Module 9 – Counting, probability and statistics

Permutations and arrangements

Count arrangements with the multiplication principle and nPr: repeated digits, identical letters, together or apart, round tables and the rank of a word.

  • Intermediate
  • 35 minutes
  • Examples run with Node.js 24.21.0, Python 3.14.8 and Pyodide 314.0.7
  • By MySmartCoPilot
Free core, Pro depth: 10 of 35 minutes free
Free: The two principles and nPr · Conditions and their methods · Five solved examples · Exercise: arrangements and the rank of a word. With a pass: 3 in-depth parts and 3 interview answers, about 25 minutes.

What you will learn

  • Apply the multiplication and addition principles of counting
  • Count arrangements with repetition, identical items and restrictions
  • Count circular arrangements and find the rank of a word

Permutations are arrangements of objects in a definite order, and two rules count them. The multiplication principle says that when one choice follows another, the numbers of ways multiply; the addition principle says that when a task can be done in one of several separate ways, the numbers add. Filling first, second and third place from 5 runners gives 5 × 4 × 3 = 60 arrangements, written 5P3. Aptitude items then change one condition: digits that may repeat, letters that are identical, people who sit together or apart, a round table instead of a row, or a word’s position in dictionary order. Each condition has a short method, set out below with five solved examples, an exercise and ten untimed questions.

The two principles and nPr

NCERT’s Class 11 textbook calls the multiplication rule the fundamental principle of counting. A thali with one of 4 curries and one of 3 breads can be served in 4 × 3 = 12 ways; an order of either one of 4 curries or one of 3 desserts can be placed in 4 + 3 = 7 ways. Permutations of r objects taken from n different objects number nPr = n!/(n − r)!, where n! = n × (n − 1) × … × 1 and 0! = 1. When an object may be used again, every place has all n choices, so there are nʳ arrangements: a 4-digit PIN has 10⁴ = 10,000.

Three ways to count arrangements: 5 × 4 × 3 places, a glued block of A and B for "together", and gaps between seated people for "apart".1. Places in order: 3 of 5 runners5×4×3= 60 wayschoices left for 1st, 2nd and 3rd place: 5P32. Together: glue Asha and BalaA BCDE4! × 2! = 484 units in a row, then A and B swap inside the block3. Apart: seat the others, then use the gapsCDE3! × 4P2 = 72C, D, E in 3! orders; A and B take 2 of the 4 gaps, in order

Places in order, a glued block for "together" and gaps for "apart"

Text description of the diagram

The figure has three rows.

The first row counts the ways to fill 1st, 2nd and 3rd place from 5 runners. Three boxes hold the choices left for each place, 5, 4 and 3, joined by multiplication signs: 5 × 4 × 3 = 60, which is 5P3.

The second row counts seatings of five friends in a row when Asha and Bala sit together. A and B are glued into one wide box, followed by single boxes C, D and E: four units arranged in 4! = 24 orders, times 2! = 2 orders of A and B inside the block, gives 48.

The third row counts the seatings with Asha and Bala apart. C, D and E sit first, with a dashed gap before, between and after them: four gaps. C, D and E have 3! = 6 orders, and A and B take two different gaps in order, 4P2 = 12 ways, so 6 × 12 = 72. This agrees with 5! − 48 = 120 − 48 = 72.

Conditions and their methods

Condition Method Example
Identical items Divide by the orders of each repeated item: n!/(p! q! …) MISSISSIPPI: 11!/(4! × 4! × 2!) = 34,650
Some must be together Glue them into one unit, then multiply by their own orders Row 2 of the figure
Some must be apart All arrangements minus “together”, or seat the others and use the gaps Row 3 of the figure
A round table (n − 1)!, because turning the table changes no one’s neighbours 6 people: 5! = 120
A necklace (n − 1)!/2 for 3 or more beads, because turning it over changes nothing either 5 beads: 4!/2 = 12
A word’s rank Count the words that start with smaller letters, one position at a time PUNE is 18th

For PUNE, put the letters in order: E, N, P, U. Words that begin with E or N come first, 2 × 3! = 12 of them. After P, the letters left that come before U are E and N, which start 2 × 2! = 4 more words, and after PU, E comes before N, which adds 1. That is 17 words before PUNE, so its rank is 18.

Five solved examples

  1. Three posts. A class of 8 elects a president, a secretary and a treasurer, and nobody holds two posts. The posts differ, so order matters: 8P3 = 8 × 7 × 6 = 336.
  2. Even numbers. Four-digit even numbers made from the digits 1 to 6: if digits may repeat, the last place has 3 choices and the others 6 each, so 6 × 6 × 6 × 3 = 648. If no digit repeats, fill the last place first: 3 × 5P3 = 180. Starting with the restricted place is the habit that prevents most errors.
  3. Identical letters. ALLAHABAD has nine letters, with four A’s and two L’s, so it has 9!/(4! × 2!) = 3,62,880 ÷ 48 = 7,560 arrangements.
  4. Never together. Five friends sit in a row, and Asha and Bala will not sit side by side. All seatings: 5! = 120. Together, glued into one unit: 4! × 2! = 48. Apart: 120 − 48 = 72. The gaps agree: seat the other three in 3! ways, then give Asha and Bala 2 of the 4 gaps in order, 4P2 = 12 ways, and 6 × 12 = 72.
  5. A round table. Seven people sit at a round table, and Bala and Chitra must sit next to each other. Glued together they make 6 units, which go round the table in 5! = 120 ways, and the pair has 2 orders: 240.
The five examples and the rank of PUNE, counted by listing every arrangement Python · five/check_five.py
# The five solved examples of the lesson and the rank of PUNE, each counted twice: once with the formula and once
# by listing every arrangement with itertools. Then nPr is checked against a full listing for every n up to 8.
from itertools import permutations, product
from math import factorial, perm


def grouped(n):
    """Digits grouped the Indian way: 7,560 and 3,62,880."""
    s = str(n)
    if len(s) <= 3:
        return s
    head, tail = s[:-3], s[-3:]
    pairs = []
    while len(head) > 2:
        pairs.insert(0, head[-2:])
        head = head[:-2]
    return ','.join([head, *pairs, tail])


def listed(items, keep=lambda arrangement: True, length=None):
    """How many different arrangements of the items pass the test (identical letters give one arrangement)."""
    return len({a for a in permutations(items, length) if keep(a)})


# 1. President, secretary and treasurer from 8 students: 8P3.
print(f"1. Three posts from 8 students: 8P3 = {perm(8, 3)}, listed {listed(range(8), length=3)}")

# 2. Four-digit even numbers from the digits 1 to 6, with and without repeating a digit.
digits = range(1, 7)
with_repeats = sum(1 for d in product(digits, repeat=4) if d[-1] % 2 == 0)
without = listed(digits, keep=lambda d: d[-1] % 2 == 0, length=4)
print(f"2. Even, digits may repeat: 6 × 6 × 6 × 3 = {6 * 6 * 6 * 3}, listed {with_repeats}; "
      f"no repeats: 3 × 5P3 = {3 * perm(5, 3)}, listed {without}")

# 3. The letters of ALLAHABAD: four A's and two L's.
formula = factorial(9) // (factorial(4) * factorial(2))
print(f"3. ALLAHABAD: 9!/(4! × 2!) = {grouped(formula)}, listed {grouped(listed('ALLAHABAD'))} "
      f"among {grouped(factorial(9))} orders of the nine letters")

# 4. Five friends in a row; Asha and Bala never sit side by side.
apart = lambda row: abs(row.index('A') - row.index('B')) != 1
print(f"4. Never together: 5! − 4! × 2! = {factorial(5) - factorial(4) * 2}, "
      f"gaps 3! × 4P2 = {factorial(3) * perm(4, 2)}, listed {listed('ABCDE', keep=apart)}")

# 5. Seven people at a round table; Bala and Chitra sit side by side. Seatings that differ only by a rotation are
# the same, so Asha is fixed in seat 0 and the other six fill seats 1 to 6.
def side_by_side(rest):
    table = ('A',) + rest
    gap = (table.index('B') - table.index('C')) % 7
    return gap in (1, 6)

print(f"5. Round table, pair together: 2 × 5! = {2 * factorial(5)}, "
      f"listed {listed('BCDEFG', keep=side_by_side)} of the {factorial(6)} seatings")

# The rank of PUNE among its arrangements in dictionary order.
orders = sorted(''.join(a) for a in permutations('PUNE'))
print(f"Rank of PUNE: 2 × 3! + 2 × 2! + 1 × 1! + 1 = {2 * 6 + 2 * 2 + 1 + 1}, listed {orders.index('PUNE') + 1}")

# nPr = n!/(n − r)! against a full listing for every 1 <= r <= n <= 8.
pairs = [(n, r) for n in range(1, 9) for r in range(1, n + 1)]
agree = sum(1 for n, r in pairs if factorial(n) // factorial(n - r) == listed(range(n), length=r))
print(f"nPr matched the listing for {agree} of {len(pairs)} pairs (n, r) with n up to 8")

Output

1. Three posts from 8 students: 8P3 = 336, listed 336
2. Even, digits may repeat: 6 × 6 × 6 × 3 = 648, listed 648; no repeats: 3 × 5P3 = 180, listed 180
3. ALLAHABAD: 9!/(4! × 2!) = 7,560, listed 7,560 among 3,62,880 orders of the nine letters
4. Never together: 5! − 4! × 2! = 72, gaps 3! × 4P2 = 72, listed 72
5. Round table, pair together: 2 × 5! = 240, listed 240 of the 720 seatings
Rank of PUNE: 2 × 3! + 2 × 2! + 1 × 1! + 1 = 18, listed 18
nPr matched the listing for 36 of 36 pairs (n, r) with n up to 8

Recorded with Python 3.14.8 on macOS 26 arm64. To run it yourself: mise exec python@3.14.8 -- python3 check_five.py

The program lists every arrangement with Python’s itertools.permutations and keeps the ones that fit, so no formula is involved in its counts. It also compared nPr with a full listing for all 36 pairs of n and r with n up to 8, and every pair agreed.

Permutation & Combination Calculator It gives nPr, circular and word arrangements as exact counts, so you can check these examples and items of your own.

Exercise: arrangements and the rank of a word

The exercise turns the rank method into a short program that also handles repeated letters, and the ten questions after it are untimed.

Exercise · Medium · Python

Count the arrangements of a word and find its rank

Write two functions in ranks.py, the file the tests import. A word is a string of capital letters, and a letter may appear more than once.

  • arrangements(word) returns how many different arrangements its letters have: arrangements("PUNE") is 24 and arrangements("ALLAHABAD") is 7,560, because swapping two identical letters gives the same word.
  • rank(word) returns the word's position when all its different arrangements are listed in dictionary order, counting from 1: rank("PUNE") is 18, as in the lesson.

Work the counts out with factorials instead of listing the arrangements: the tests include VISAKHAPATNAM, whose 13 letters can be put in order in more than 622 crore ways, so a listing would not finish in time.

Starter code · ranks.py

from collections import Counter
from math import factorial


def arrangements(word):
    """How many different arrangements the letters of the word have."""
    # Replace this line with your code.
    return 0


def rank(word):
    """The word's position, from 1, among its different arrangements in dictionary order."""
    # Replace this line with your code.
    return 0
The sample tests · test_ranks.py
from ranks import arrangements, rank


def test_counts_with_and_without_repeats():
    """Four different letters, then ALLAHABAD's four A's and two L's"""
    assert arrangements("PUNE") == 24
    assert arrangements("ALLAHABAD") == 7560


def test_the_lesson_word():
    """PUNE: 12 + 4 + 1 words come before it"""
    assert rank("PUNE") == 18


def test_first_and_last_words():
    """Letters in order give the first word, letters in reverse order the last"""
    assert rank("ADGNOS") == 1
    assert rank("SONGDA") == arrangements("SONGDA")


def test_repeated_letters():
    """ASSAM has 30 different arrangements"""
    assert arrangements("ASSAM") == 30
    assert rank("ASSAM") == 11


def test_one_letter_and_all_alike():
    """A single letter, and a word whose letters are all the same"""
    assert arrangements("Q") == 1 and rank("Q") == 1
    assert arrangements("AAAA") == 1 and rank("AAAA") == 1


def test_a_long_word_without_listing():
    """Thirteen letters, four of them A: worked out, never listed"""
    assert arrangements("VISAKHAPATNAM") == 259459200
    assert rank("VISAKHAPATNAM") == 249207263
A hint

arrangements is n! divided by k! for each letter that appears k times (collections.Counter counts the letters). For rank, walk through the word from the left. At each position, every unused letter that comes before the letter actually there starts a block of smaller words: take that letter out of the remaining letters, add the number of arrangements of what is left, and put the letter back. The rank is the total of these blocks plus 1.

The sample tests run on this device, in your browser (Pyodide): nothing is sent to mysmartcopilot.com. The first run downloads Python (about 13.5 MB), which is kept for the next runs. A check in your browser is feedback for you, not proof that the code is right for every input.

Ten untimed questions on arrangements

10 questions about this lesson. Every answer and why it is right is on the page, behind “Show the answer”. Your score stays in this browser.

  1. Question 1 of 10 Six runners race. In how many ways can the first, second and third places be filled?

    Type a number.

    Show the answer to question 1

    Answer: 120

    The places differ, so order matters: 6P3 = 6 × 5 × 4 = 120. Choosing three runners without places would give only 20, one sixth as many.

  2. Question 2 of 10 How many three-letter codes can be made from the 26 capital letters if a letter may be used more than once?

    Type a number.

    Show the answer to question 2

    Answer: 17576

    Each of the three places has all 26 choices, so there are 26³ = 17,576 codes. Without repeats it would be 26P3 = 15,600.

  3. Question 3 of 10 How many different arrangements do the letters of PATNA have?

    Choose one answer.

    Show the answer to question 3

    Answer: 60

    PATNA has five letters with two A's, so 5!/2! = 60. Swapping the two A's never makes a new word, which is why 120 counts every word twice.

  4. Question 4 of 10 How many different arrangements do the letters of SILIGURI have?

    Type a number.

    Show the answer to question 4

    Answer: 6720

    Eight letters, of which three are I and the rest differ: 8!/3! = 40,320 ÷ 6 = 6,720.

  5. Question 5 of 10 Six different books stand on a shelf, and two particular books must stand side by side. In how many ways can the books be arranged?

    Type a number.

    Show the answer to question 5

    Answer: 240

    Glue the two books into one unit: 5 units have 5! = 120 orders, and the two books can stand in 2 orders inside the unit, so 120 × 2 = 240.

  6. Question 6 of 10 The same six books are arranged so that the two particular books are never side by side. In how many ways?

    Type a number.

    Show the answer to question 6

    Answer: 480

    All 6! = 720 arrangements minus the 240 with the two together leaves 480. The gaps agree: the other four books have 4! = 24 orders and leave 5 gaps, and the two books take 2 of them in order, 5 × 4 = 20 ways; 24 × 20 = 480.

  7. Question 7 of 10 In how many ways can nine people sit at a round table, if seatings that differ only by a turn of the table are the same?

    Type a number.

    Show the answer to question 7

    Answer: 40320

    Fix one person's seat to remove the turns; the other eight fill the remaining seats in 8! = 40,320 ways, which is (9 − 1)!.

  8. Question 8 of 10 How many different necklaces can be made from 7 different beads?

    Choose one answer.

    Show the answer to question 8

    Answer: 360

    Turning a necklace changes nothing, which gives (7 − 1)! = 720, and turning it over changes nothing either, which halves the count to 360.

  9. Question 9 of 10 The arrangements of the letters of MANGO are listed in dictionary order. In which position does MANGO itself come?

    Type a number.

    Show the answer to question 9

    Answer: 51

    In order the letters are A, G, M, N, O. Words starting with A or G: 2 × 4! = 48. After M, the second letter A has nothing smaller left. After MA, the third letter N has G before it: 2! = 2 words. After MAN, G is the smallest letter left. So 50 words come first and MANGO is 51st.

  10. Question 10 of 10 A canteen sells 4 kinds of dosa and 3 kinds of uttapam. In how many ways can a customer buy exactly one item?

    Choose one answer.

    Show the answer to question 10

    Answer: 7

    The customer buys a dosa or an uttapam, two separate cases, so the addition principle applies: 4 + 3 = 7. The product 4 × 3 = 12 would count buying one of each.

Ten harder arrangement items with full working, and the trap in each Pro: opens with a Pro, Premium or Ultimate pass

Harder arrangement items join two conditions: a digit rule with a range, repeated letters with a position rule, or a round table with a pattern. The ten original items below are worked in full, and each ends with the answer a hurried solver most often gives.

In this part:

  • Digits with a range or a divisibility rule, worked
  • Vowels kept together, and vowels in fixed places
  • Round tables with a pattern, and necklaces
  • A rank with repeated letters, and the sum of many numbers
  • Order without adjacency, and gaps for identical letters

1 runnable example (Python) · about 4 minutes

Opening this part with your pass…

This part opens with any MySmartCoPilot pass.

  • Pro pass · 1 week₹79$2.99
  • 30 days₹179$5.99
  • 1 year₹1,699$45

One payment; a pass never renews. The price shown is the total you pay: no fees or charges are added at checkout.

It also opens every other in-depth part in Learn and every Pro tool. Sales are final, except where the law gives you a right to withdraw, for example in the EU and the UK (refund policy).

Why the formulas hold, and the two places they break Pro: opens with a Pro, Premium or Ultimate pass

Each arrangement formula is a short argument, and knowing the argument is what lets you adapt a formula when an item changes. This part proves the three that matter most, reproduces the two cases where a formula gives a wrong count, and measures how quickly n! grows.

In this part:

  • Identical letters divide: a proof by labelling
  • Turns and flips: round tables, necklaces and where the formula fails
  • Two readings of “not together”, reproduced
  • How fast n! grows, in numbers

1 runnable example (Python) · about 3 minutes

Opening this part with your pass…Pro part. It opens with the same pass as the part above.

A 12-minute set of ten items, with answers and a rubric Pro: opens with a Pro, Premium or Ultimate pass

Ten items cover every method of the lesson, at a little over a minute each. Start a 12-minute timer and work all ten before reading the answers, which follow with their working and a rubric for your score.

In this part:

  • Ten mixed items, 12 minutes
  • The answers, each with its shortest working
  • What your score says, as a rubric

1 runnable example (Python) · about 3 minutes

Opening this part with your pass…Pro part. It opens with the same pass as the part above.

Interview questions

  1. Fresher · Warm-up

    Why is 0! equal to 1, and where does that matter when you count arrangements?

    n! counts the orders of n different objects, and there is exactly one way to arrange nothing: leave it as it is. The formulas need that value too. nPr = n!/(n − r)! must give n! when r = n, which works only if 0! = 1; and the rule n! = n × (n − 1)! gives 1! = 1 × 0!, so 0! = 1 again. It matters whenever a formula divides by a factorial that can be 0!: arranging all 4 letters of PUNE is 4P4 = 4!/0! = 24 ways, and a word whose letters all appear once divides by 1! for each letter, which changes nothing. Taking 0! as 0 would make these formulas divide by zero.

  2. Fresher

    Eight guests sit at a round table, and two of them refuse to sit side by side. Count the seatings in two independent ways, and explain how the count changes if one chair is marked as the head of the table.

    Model answer, Pro. Model answers open with any pass; prices are in the notice on this page. First step and follow-ups

  3. Fresher

    Find the rank of KOLKATA among its different arrangements in dictionary order. Explain the method, the step that most often goes wrong with repeated letters, and a quick check that your rank is possible.

    Model answer, Pro. First step and follow-ups

  4. Fresher

    How many four-digit even numbers with four different digits can be made from 0, 1, 2, 3, 4 and 5? Explain why the count must be split into cases, and how you would check it.

    Model answer, Pro. First step and follow-ups

Key takeaways

  • Multiply when one choice follows another; add when the cases are separate.
  • nPr = n!/(n − r)!, and with repetition allowed there are nʳ arrangements.
  • Identical items divide the count: n!/(p! q! …).
  • Together: glue the group into one unit. Apart: subtract the together count, or use the gaps.
  • A round table has (n − 1)! seatings and a necklace (n − 1)!/2, for three or more beads.
  • A word’s rank counts the words that start with smaller letters, one position at a time.

References

Related tools

Report a problem with this lesson

Quick answers and tool search

Type to search tools or to get a quick answer, for example 18% of 2500. Use the up and down arrow keys to move through the results, Enter to choose, and Escape to close.