Project 2, CSC 202
1 Huffman Coding
For this project, you will implement a program to encode and decode text using Huffman coding .
Here’s the invitation link for this project.
Here’s a link to the project description.
2 Design Recipe
For each function required in this assignment, you should follow the design recipe, as described in this document. Specifically, each function should come with a purpose statement, types for both parameters and return type, and a full set of tests (unless the specification states that no tests are required for a particular function).
3 A note about automated testing
You should use an @dataclass(frozen=True) decorator to define all classes created in this assignment, except where specifically instructed.
4 Import restrictions
In order to make it possible to test and analyze your code, it’s important that we be able to run it in a consistent environment.
Specifically, we will run your code with Python 3.13, in an environment that includes only the standard packages along with mypy. Please don’t import packages other than dataclass, typing, unittest, sys, string and math, and of course other parts of your own source code. If I’ve left something important off this list, let me know!
5 Handin instructions
Submit this assignment using Gradescope. Please please please submit as a team, if you’re working as a pair.
6 Automated Testing
We will be using some automated testing in order to check the correctness of your code. For this reason, it’s important that names be spelled as specified, and that fields and parameters occur in the order specified in the text.
Please note that the repository also contains a file called "test_basic.py". These tests don’t verify that your code is correct, they simply verify that you have defined the right functions, and that they have the right number of arguments, and that they return the right kind of thing. These tests exist because it’s very sad when you are supposed to develop a function named (say) "success" and you accidentally name it (say) "succcess" and then all of the tests fail.
You can run these tests yourself, using
python3 test_basic.py |
... or by running this file in your favorite IDE.
These tests are also run for you when you submit to Gradescope, and you should be able to see the results there.
In general, files that don’t pass the basic tests may receive a score of zero on the assignment.
Please note that editing the "test_basic.py" file is a terrible idea; the whole
point of "test_basic.py" is to ensure that the post-submission tests run correctly;
editing this file is like using chewing gum to stick the needle of your thermometer to 80 degrees
—