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]

Clone this wiki locally
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.