title: Create all permutations of 4 letters
body: <p>I want to create an array of all permutations of a series of 4 letters (Call them A,C,G,T for the 4 types of nucleotide bases). The program should ask the user for the value of k, the length of the permutation. I've got it working to the point where I can get the permutations, but it only shows the ones with no repeats. Here's the program, the output it's giving me right now, and the output I want it to give me.</p>
  
  <pre><code>import java.util.Arrays;
  import TerminalIO.*;
  public class Permute {
      static KeyboardReader reader= new KeyboardReader ();
      static int k= reader.readInt("Enter k-tuple");
      static void permute(int level, String permuted,
                          boolean[] used, String original) {
  
          if (level == k) {
              System.out.println(permuted);
          } else {
              for (int i = 0; i &lt; 4; i++) {
                  if (!used[i]) {
                      used[i] = true;
                      permute(level + 1, permuted + original.charAt(i), used, original);
                      used[i] = false;
                  }
              }
          }
      }
  
      public static void main(String[] args) {
          String s = "ACGTACGTACGTACGTACGT";
          boolean used[] = new boolean[20];
          Arrays.fill(used, false);
          permute(0, "", used, s);
      }   
  }
  </code></pre>
  
  <p>When I enter a K value of 2,it gives me:</p>
  
  <ul>
  <li>AC</li>
  <li>AG</li>
  <li>AT</li>
  <li>CA</li>
  <li>CG</li>
  <li>CT</li>
  <li>GA </li>
  <li>GC</li>
  <li>GT</li>
  <li>TA</li>
  <li>TC</li>
  <li>TG</li>
  </ul>
  
  <p>Ideally, it would print:</p>
  
  <ul>
  <li>AC</li>
  <li>AG</li>
  <li>AT</li>
  <li>AA</li>
  <li>CA</li>
  <li>CC</li>
  <li>CG</li>
  <li>CT</li>
  <li>GA </li>
  <li>GG</li>
  <li>GC</li>
  <li>GT</li>
  <li>TA</li>
  <li>TC</li>
  <li>TG</li>
  <li>TT</li>
  </ul>