TL;DR
Augment your unstarred-tick submission to compress and decompress actual files. The compressed file must include the Huffman code needed to decompress it.
Details
Rename your huffman.py
as huffmanf.py
. Make it accept an option and a filename on the command line.
If the command-line option -e
is supplied, huffman-encode the file to a new file. When doing so, include all necessary decoding information to the encoded file (the mapping between codewords and symbols, as well as the original filename), so that the supplied file is self-contained and can be decoded without having access to the HuffmanCode
object that generated it. In other words, you must also define a compact and unambiguous specification for “your” Huffman-encoded files, and implement it.
If the command line option -d
is supplied, write out the decoded file.
No extra course credit will be awarded for the completion of any optional extras.
What to do
Complete the unstarred tick first and ensure huffman.py
passes pycodestyle
(mandatory for the starred tick) as well as the autotester.
Write and debug your own huffmanf.py
, starting from your own huffman.py
(no template supplied). Ensure that it too passes pycodestyle
.
Upload huffmanf.py
to Moodle.
There is no autotester to help you debug your code. Consider writing your own tests (not required and you won’t be able to submit them to Moodle, but you might discuss them if you are selected for a viva).