package math.convert;


/*************************************************************************
 *  Compilation:  javac Rumpelstiltskin.java Converter.java
 *  Execution:    java Rumpelstiltskin N
 *  
 *  Enumerate all alphanumeric strings of <= N characters.
 *  Counts from 0 to 36^N - 1 and converts to base 36.
 *  Not the most efficient method, but amazingly little code!
 *
 *  Sample execution:
 *
 *     % java Rumpelstiltskin 4
 *     0
 *     1
 *     ...
 *     ZZZZ
 *     
 *
 * Warning: algorithm only works for N <= 5 since 36^6 will overflow
 * an int.  But this prints out 60,466,176 strings. Use a long to go
 * up to N = 12, but be prepared to wait centuries!
 *
 *************************************************************************/

public class Rumpelstiltskin { 

   public static void main(String[] args) { 
//      int N = Integer.parseInt(args[0]);
      int N = 4;

      for (int i = 0; i < Math.pow(36, N); i++)
         System.out.println(Converter.toString(i, 36));
   }
}
