public static void compress() { String s = BinaryStdIn.readString(); int n = s.length(); BinaryStdOut.write(n); for (int i = 0; i < n; i++) { int index = DNA.toIndex(s.charAt(i)); BinaryStdOut.write(index, DNA.lgR()); } BinaryStdOut.close(); }
public static void expand() { int n = BinaryStdIn.readInt(); int w = DNA.lgR(); for (int i = 0; i < n; i++) { char c = BinaryStdIn.readChar(w); BinaryStdOut.write(DNA.toChar(c)); } BinaryStdOut.close(); StdOut.println(); StdOut.println(); }