refactor hamming.rb using each_with_index