The Ryser formula expresses the permanent of an matrix,
where
is a positive integer, as
where the sum is over all subsets of , and
is the number of elements in
. The formula can be optimized by picking the subsets
so that only a single element is changed at a time (which is precisely a Gray
code), reducing the work per term from
to
.
The label of the disk moved at the th step in the standard optimal three-rod tower
of Hanoi solution is the element changed at the
th transition of the binary reflected Gray
code ordering of these subsets (Gardner 1988b; Vardi
1991, p. 111).