# Sample programs

The programs here are written in C++, using
the CWEBx system
of software documentation. Links are provided to the tangled (directly
compilable) sources and the generated documentation in PDF format, so to use
and inspect the programs it is not necessary to install the CWEBx system.
## Combing lattice paths to obtain tilings of the Aztec diamond

This program will apply the algorithm described in the paper
"A bijection proving the Aztec diamond theorem by
combing lattice paths", either on a random array of bits to generate a
random path family, or exhaustively on all possible such data of a given
order; it also runs the reverse algorithm checking that it recovers the
initial data. It can produce PostScript data depicting the path family
produced, and optionally several intermediate stages, and the corresponding
Aztec diamond tiling.
The program is a command line program taking its arguments from the command
line. Assuming the executable program is named `aztec`, the calling
syntax is
aztec [OPTIONS] ORDER [FILE]

where `ORDER` is the order of the Aztec diamond to consider (a
nonnegative number; the path family will contain one more path than this). The
final argument `FILE` is a base for the name of the PostScript file to
be produced; the program will automatically add "`-ORDER.ps`" to it. If
no `FILE` argument is given but PostScript output is requested, it will
be written to the standard output. The default is to output one randomly
generated path family of the given order, but this can be modified by options.
The possible options are
`-x` Do exhaustive generation in given order, while suppressing
PostScript output; just report success or failure of
executing the algorithm and inverting it
`-X` Do exhaustive generation, and produce (potentially massive)
PostScript output
`-t` Produce (also) output of the completed configuration as
a tiling of the Aztec diamond
`-n` Suppress output of a path family
`-s NUM` Write, to the PostScript output, `NUM`
intermediate snapshots during the algorithm, done at more or less equally
spaced times when complete columns have been made disjoint, the first
snapshot being at the very beginning. Setting this option also causes
"`-NUM`" to be inserted into the file name produced, just before
the dot. An alternative syntax for setting this option is to
specify `ORDER` in the form *n*/*s* where *n* is the
order and *s* the number of snapshots.
`-c NUM` Write, to the PostScript output, in detail the stages
during which column number `NUM` is made disjoint and obtains its
final value; this happens after the path with the same number is taken into
consideration.
`-r NUM` Set the random seed to `NUM`, so that
reproducible output can be generated.

## A bijection between partitions of *n* and strict partitions of 2*n*
whose diagram is black/white balanced

This is a small Python program that computes the bijections described in these
MathOverflow
and Math.StackExchange
answers. They are between partitions of *n* on one hand and on the other
hand strict partitions of 2*n* with empty 2-core, where the latter means
that the diagram when coloured in a checkerboard fashion has as many black as
white squares, or equivalently that the odd parts of the partition (which are
even in number) occupy as many odd as even positions.
This is my very first Python program, so it might contain things that are
frowned upon by the Python community.
The forward direction is computed by `double_strict` using edge
sequences, and also by `to_double` using the more direct approach of the
StackExchange answer (the two functions should produce the same results).
Similarly the reverse direction (which is actually the one described in the
answers) is computed by `undouble` using edge
sequences, and also more directly by by `to_plain`.