Update original code to use the template.
Added code for calculating Hamming distance.