public static void compress(){
  Alphabet DNA=Alphabet.DNA;
  String s=BinaryStdIn.readString();
  int n=s.length();
  BinaryStdOut.write(n);
  for (int i=0; i < n; i++) {
    int d=DNA.toIndex(s.charAt(i));
    BinaryStdOut.write(d,2);
  }
  BinaryStdOut.close();
}

public static void compress ( ) { Alphabet DNA = Alphabet . DNA ; String s = BinaryStdIn . readString ( ) ; int n = s . length ( ) ; BinaryStdOut . write ( n ) ; for ( int i = 0 ; i < n ; i ++ ) { int d = DNA . toIndex ( s . charAt ( i ) ) ; BinaryStdOut . write ( d , 2 ) ; } BinaryStdOut . close ( ) ; }
reads a sequence of 8 - bit extended ascii characters over the alphabet { a , c , t , g } from standard input ; compresses them using two bits per character ; and writes the results to standard output .
