Add the file codetools1.R
to the R
subdirectory of your project.
Implement the functions hammingDistance
and
codeDistance
as described in the documentation. The
codeDistance
function needs to find the smallest Hamming
distance between any two words in the code. We are representing code
words as numeric vectors of 0’s and 1’s, and we are representing codes
as matrices of 0’s and 1’s (numeric), where the rows of the matrix are
the code words.
Implement generateCode
as specified. This function
consumes a matrix representing the basis code words, and
returns a matrix whose rows are all of the code words, i.e.,
all of the possible linear combinations over \(\mathbb{Z}_2\) of the basis code words,
without duplicates. Notice that the provided example in the
documentation uses the basis for the Hamming [7,4] code discussed in the
notes. (You may assume that the basis will never contain more than 32
words.)