NAME

permute - Generate permutations of numbers.

SYNOPSIS

permute n cmd

DESCRIPTION

permute n cmd
Given a number n, this command will generate n! strings. Each string is a unique permutation of the numbers from 0 to n - 1. For example, if n is 3, the following strings are generated:

0 1 2
0 2 1
2 0 1
2 1 0
1 2 0
1 0 2

The cmd argument is a Tcl command that is invoked for every permutation that is generated. This command must accept a single argument. The argument will be a Tcl list consisting of the permuted numbers. To print the permutations to the screen, one could use the Tcl command puts:

permute 3 puts

Or the command could be defined by the user and do something like set the key for a columnar cipher to the permuted string.


Back to the Index
wart@kobold.org
Created on Wed Mar 31 08:18:25 PST 2004
SourceForge.net Logo