subset, a MATLAB code which enumerates, generates, randomizes, ranks and unranks combinatorial objects including combinations, compositions, Gray codes, index sets, partitions, permutations, polynomials, subsets, and Young tables. Backtracking routines are included to solve some combinatorial problems. Other routines handle continued fractions, Diophantine equations, and Pythagorean triples.

Combinatorial operations include the enumeration, generation, random selection, ranking and unranking of

Other objects considered include


The computer code and data files described and made available on this web page are distributed under the GNU LGPL license.


subset is available in a C version and a C++ version and a FORTRAN90 version and a MATLAB version and an Octave version and a Python version.

Related Data and Programs:


backtrack_binary_rc, a MATLAB code which carries out a backtrack search for a set of binary decisions, using reverse communication.

combination_lock, a MATLAB code which simulates the process of determining the secret combination of a lock.

combo, a MATLAB code which contains many combinatorial routines.

gray_code_display, a MATLAB code which computes the hamming distance tables for both the binary and gray codes, and displays 3d plots that illustrate how the gray code does a better job of providing nearby representations for nearby numbers.

monomial, a MATLAB code which enumerates, lists, ranks, unranks and randomizes multivariate monomials in a space of m dimensions, with total degree less than n, equal to n, or lying within a given range.

partition_brute, a MATLAB code which uses a brute force method to find solutions of the partition problem, in which a set of integers must be split into two subsets with equal sum.

partition_greedy, a MATLAB code which uses a greedy algorithm to seek a solution of the partition problem, in which a given set of integers is to be split into two groups whose sums are as close as possible.

polynomial, a MATLAB code which adds, multiplies, differentiates, evaluates and prints multivariate polynomials in a space of m dimensions.

polynomial_multiply, a MATLAB code which multiplies two polynomials p(x) and q(x).

set_theory, a MATLAB code which demonstrates MATLAB commands that implement various set theoretic operations.

subset_sum, a MATLAB code which seeks solutions of the subset sum problem.

toms515, a MATLAB code which can select subsets of size k from a set of size n. this is a version of acm toms algorithm 515, by bill buckles, matthew lybanon.

unicycle, a MATLAB code which considers permutations containing a single cycle, sometimes called cyclic permutations.

Source Code:

Last revised on 13 November 2022.