Hexagonal Grid

Back to Problem Solutions forum

hogarth45     2015-01-29 15:51:46
User avatar

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.

Quandray     2015-01-29 16:33:28
User avatar

On your map, I think you've done BCA not BCB.

Rodion (admin)     2015-01-29 18:01:41
User avatar

Yes, I think "BCB" means:

  • up-left (B)
  • up-right (C)
  • up-left (B)

so you should end up somewhere further than you draw...

hogarth45     2015-01-29 18:16:51
User avatar

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.

Rodion (admin)     2015-01-29 18:30:55
User avatar

>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.

hogarth45     2015-01-29 20:24:44
User avatar

D'oh, that was harder than I thought. I'm starting to get hit by the learning curve.

Rodion (admin)     2015-01-29 20:49:21
User avatar

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...

Please login and solve 5 problems to be able to post at forum