Helper script for permutations (ultimately for problem 24).
Problem 24.