// Collection of code snippets by Arne Vajhøj 
// (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
public class WGen {
    private static void gen(char[] c, int ix, int n, char[] base) {
        if(ix < n) {
            for(int i = 0; i < base.length; i++) {
                c[ix] = base[i];
                gen(c, ix+1, n, base);
            }
        } else {
            System.out.println(new String(c));
        }
    }
    private static void gen(int n, char[] base) {
        char[] c = new char[n];
        gen(c, 0, n, base);
    }
    public static void main(String[] args) {
        char[] base = "abcdefghijklmnopqrstuvwxyz".toCharArray();
        gen(1, base);
        gen(2, base);
    }
}
