Sped up hamming_distance by using precomputed hex distances