Projects‎ > ‎

Project1

Hamming Code in Python

Due: Mon Sep 14 2015 at 11:59pm in your Github repo for project1 (I will provide the repo).



This is a Python warm up project. You are going to implement a Hamming Code encoder, decoder, error finder, and error corrector in Python.

See this page for details on the Hamming Code calculation: http://users.cs.fiu.edu/~downeyt/cop3402/hamming.html


You should write a Python program called hamming that accepts the following command line arguments:

$ python hamming.py <type> <command> <arg1> <arg2>

Where <type> is one of:
  • asc - ASCII encoding
  • bin - Binary encoding
Where <command> is one of:
  • enc <infile> <outfile>
    • Encode
  • dec  <infile> <outfile>
    • Decode
  • chk <infile>
    • Check
  • fix <infile> <outfile>
    • Fix
  • err <pos> <infile> <outfile>
    • Create an error at bit postion <pos>
For example,

$ python hamming.py asc enc hello.txt hello.asc

Will encode the ASCII file into a hamming code version of the file in which each character is a '0' or a '1'. You can assume you will encode 8 bit values.

Using the ASCII encoding keeps things simple while you are developing your hamming code algorithm.

The Binary encoding is more compact as the resulting encoded file will be binary data instead of ASCII data. However, you will need to use bitwise operators to build up your result file.

You should structure your program using Python classes in order to reuse as much code as possible. Also try to use as much functional style programming as possible. See:


You can break down your program into multiple files.

You will need to write test code for your solution.

Deliverables

  • The Python source for the hamming encoder
  • A README that describes your design
  • Test code that verifies the correctness of your code:
    • I should be able to look the test code and understand it
    • I should be able to run all the tests from the command line
    • There should be output that indicates the tests pass
  • Your solution should be submitted in your Github repo (I will provide the repo)

ċ
hello.asc
(0k)
Greg Benson,
Sep 3, 2015, 6:28 PM
ċ
hello.bin
(0k)
Greg Benson,
Sep 3, 2015, 6:28 PM
ċ
hello.txt
(0k)
Greg Benson,
Sep 3, 2015, 6:28 PM
ċ
test_hamming.sh
(1k)
Greg Benson,
Sep 17, 2015, 5:59 PM
Comments