// PermutationExample.java SJ import java.util.Iterator; import java.lang.Iterable; public class PermutationExample { public static void main(String[] args) { int N = 4, K = 6; PermutationExample l = new PermutationExample(); if (args.length > 0) N = Integer.valueOf(args[0]); if (args.length > 1) K = Integer.valueOf(args[1]); Permutation P = new Permutation(N); // Permutation P = new Permutation(N, 42); // random seed System.out.println("All permutations:"); for (int[] perm : P) { if (N <= 6) { // not for large N for (int i = 0; i < N; i++) System.out.print(perm[i] + " "); System.out.println(); } } System.out.println("Some random permutations:"); for (int s = 0; s < K; s++) { int[] perm = P.randomPermutation(N); for (int i = 0; i < N; i++) System.out.print(perm[i] + " "); System.out.println(); } System.out.println("Random permutations of different size:"); for (int s = 1; s <= K; s++) { int[] perm = P.randomPermutation(s); for (int i = 0; i < s; i++) System.out.print(perm[i] + " "); System.out.println(); } } // main() }