refactor ruby hamming