Solution for the Hamming problem