Back to Problem Solutions forum
Hello
Working on Hex Grid
3
AABF
FEDCBA
BCB
answer:
3.0 0.0 2.64575131
I drew a map of my confusion!
http://i.imgur.com/8onB3rv.jpg
What is boils down to is, how does BCB get you 2.6?
From all sources I read on this problem, it should be 2.
Yes, I think "BCB" means:
so you should end up somewhere further than you draw...
Updated the map
http://i.imgur.com/S74aqYk.jpg
All the distance algorithms I find are as such. Distance = Max(x1-x2,y1-y2,x-y)
http://keekerdc.com/2011/03/hexagon-grids-coordinate-systems-and-distance-calculations/
Nothing to do with decimals.
Even trying to solve it with Pythagriums therom:
http://i.imgur.com/CmQndvu.jpg
I might have to just come back to this one after I get smarter.
>Max(x1-x2,y1-y2,x-y)
I'm afraid this formula is not for geometric distance, but for logic distance (amount of moves to travel) or something like this.
>Even trying to solve it with Pythagriums therom:
This approach is correct, but you make one small mistake - distance between vertical rows is not 1 (because 1 is distance between centers of, say, X and B), so full vertical distance is not 3.
I believe it is something like sqrt(3)/2
i.e. 0.866
but I may remember incorrectly so it is good to check if you can.
Ah, please do not feel frustrated. You see, math and geom related problems are bit special because they more rely on some non-programming knowledge so they are not of the first importance.
Another thing to consider is that problems are arranged not by actual difficulty but by the number of people who solved them. So sometimes more tricky but older problems are encountered slightly earlier than they should be...