liveBook · Manning

Permutation

As explained in Get Programming: Learn to code with Python

A permutation is an arrangement of selected items in which order distinguishes the arrangement.

A permutation is an arrangement of selected items where order matters. Two lists can contain the same elements and still represent different arrangements when their order differs. section 26.5

Comparing lists

The lists [1, 2, 3] and [3, 1, 2] are permutations of each other because they contain the same elements in a different order. Duplicate elements count too: [1, 1, 1, 2] and [1, 2, 1, 1] match, but [1, 2, 3, 1] and [1, 2, 3] do not because one list has an extra 1. section 26.5

When solving a tile-word problem, considering every possible permutation is one possible strategy. A simpler approach checks each valid word letter by letter and stops as soon as a required letter is unavailable. section 19.1

A permutation check should verify that:

How Get Programming: Learn to code with Python covers it

How deep it goes
Defines permutations with list examples and exercises, but stops short of implementing the permutation-checking function.
Examples
Uses integer lists with reordered and repeated values, plus Scrabble tiles whose letters could form valid words.
What you can do after
Apply the concept by checking whether two lists contain identical elements with identical counts despite different ordering.
How it connects
Connects permutations to lists, element membership, duplicate values, and combinations.

Also explained in

Compare how 9 books explain permutation →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Get Programming: Learn to code with Python. The section links point to the parts of the book it draws on.