Open Algorithms

Permutation functions

A function with a finite domain and range we'll call a finite function. A finite function with equal domain and range we'll call a permutation function. Such a function has the property of becoming the identity function after a finite number of applications. Here's an example:

f(0) = 2
f(1) = 0
f(2) = 3
f(3) = 1

f comp f comp f comp f = id

f(f(f(f(0)))) = f(f(f(2))) = f(f(3)) = f(1) = 0
f(f(f(f(1)))) = f(f(f(0))) = f(f(2)) = f(3) = 1
f(f(f(f(2)))) = f(f(f(3))) = f(f(1)) = f(0) = 2
f(f(f(f(3)))) = f(f(f(1))) = f(f(0)) = f(2) = 3
Download C++ project (Patrons only)