Skip to content
This repository has been archived by the owner on Apr 26, 2023. It is now read-only.
AlistairIsrael edited this page Sep 13, 2010 · 7 revisions

jcombinatorics is a library written in Java that provides permutations and combinations generators and utility functions.

Generating Permutations
    for (int[] permutation : Permutations.of(2, 3, 7)) {
        System.out.println(Arrays.toString(permutation));
    }

Outputs:
  [2, 3, 7]
  [2, 7, 3]
  [3, 2, 7]
  [3, 7, 2]
  [7, 2, 3]
  [7, 3, 2]

Generating Combinations
    for (String[] combination : Combinations.of("a", "b", "c", "d", "e").take(3)) {
            System.out.println(Arrays.toString(combination));
    }

Outputs:
  [a, b, c]
  [a, b, d]
  [a, b, e]
  [a, c, d]
  [a, c, e]
  [a, d, e]
  [b, c, d]
  [b, c, e]
  [b, d, e]
  [c, d, e]