[Community Puzzle] Hexagonal Maze

Coding Games and Programming Challenges to Code Better

Send your feedback or ask for help here!

Created by @Remi,validated by @I_love_CoC,@Westicles and @DaNinja.
If you have any issues, feel free to ping them.

There is no specifications on what happens when the grid height is odd. There is such a test case and while the walls in this case resolve the issue there should either be a constraint such that h is even or you should explain the consequences of having an odd h, since you also state that all cells have six neighbors and that cant possibly be true for h odd.

Odd h is not a special case, all cells have 6 neighbours. You just need to handle the coordinates with ‘modulo h’ and ‘modulo w’, ie. the cells “rolls over” to the other side.

1 Like

Consider the following (rows 0 and 2 are left justified, row 1 is right justified):
3 3
A B C
.D E F
G H I
So all that I know is that the neighbors of G obviously include D (up right), F(up left), H (right), I (left). So what are the neighbors of G for (down right) and (down left)??? The first and last rows have the same justification for odd h. I have already solved the puzzle successfully, my point is just that there is no clear handling description for odd h.

1 Like

Now I see, you are right.
My code would consider A and C also neighbours in your example, but it is true that “the grid is periodic” sentence is not clear enough because of the shifted hexagonals.

I think that it’s not in the puzzle, ie h and w are even.

1 Like

Test case 7 is:

21 21

I mentioned that in my original message (not specifically but i mentioned that there was a test case that doesn’t cause an issue because the top and bottom rows are walled off)

That is indeed the only odd h case, odd w cases don’t need to have any special instructions since the lines are justified on a “row-by-row” basis, but not “column-by-column”, there are only two directions you can move on a row, one left or one right.

Odd h cases should be removed.

The neighboors definition seems extendable to odd h and make no difference cause you can just use the parity rule and apply h modulus, but it brings one main problem:
the neighboorhood relation isn’t symetrical anymore.

I changed the last but one test case (real hexagon) so that h is always even. The periodicity of the grid wasn’t important here, but i undersand the problem.
I also modified the statement, to indicate h is always even.

9 Likes

It was always my plan to work with hexagon fields. Never hat the time or opportunity to do it.
Lucky for me, this puzzle gave me the chance to do it.
Thanks a lot for this.

You’re welcome :slight_smile: