## Saturday, November 21, 2015

### Permutations

I'd say a Permutation is a sweet spot in computer science, in that it's a mathematical primitive that's just complicated enough to require enough code to be interesting.

You will gain some traction, in whatever language you're learning, if you can implement a Permutation in that language.

What is a Permutation then?  A one-to-one scattering of elements to themselves in another order.

Picture an arbitrary pairing of the numbers 0 through 9 with themselves again, in any order: {0: 7, 1: 1, 2: 0, 3: 6, 4: 8, 5: 4, 6: 5, 7: 3, 8: 2, 9: 9}.  In Python, the dictionary object works perfectly.

I get to teach about the Permutation type live through a microphone, then upload the source code for asynchronous inspection.

Permutations of finite elements may be multiplied, and therefore powered.  They may also be inverted, for which operation I use ~.  A permutation times its inverse is the identity permutation, which maps every element to... you guessed it, itself.