This is how I solved code war's hexadistance.