Is the testing system works as it should?

Back to Problem Solutions forum

Leonid_Manieiev     2015-05-21 20:20:01

Hello everyone

Im trying to solve Problem #73 but I cant for some reason. Here is the thing:

Am I right, that distance between two hex grid is calculating by the following formula?: distance = sqrt(pow((x2-x1), 2) + pow((y2-y1), 2))

... where x1; y1 - is a posion of initial hex grid and x2; y2 a position of last hex grid in sequence.

And also, am I right, that x and y calculating by the following rules:

letter 'A' - x++ letter 'B' - y++ letter 'C' - x--, y++ letter 'D' - x-- letter 'E' - y-- letter 'F' - x++, y--

... cause if I right, then I can tell, that testing system doesnt work as it should, but if I dont, just tell me, that Im wrong.

P.S. Im not asking for solution, Im just asking to know if the testing system works fine.

Hope to get answer

OldProgrammer     2015-05-21 23:07:04

Hello Leonid,

the first formula is correct as long as your (x, y) values are in Cartesian coordinates. The x, y calculations for the rules are not correct (except for A and D). You need to convert (non-Cartesian) moves in each of the directions in the Hexagonal Grid into moves in the x-y directions in the Cartesian system.

Hope that helps.

Leonid_Manieiev     2015-05-21 23:30:25

Thank you very much. That was helpful.

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