Implement Logic.huffman