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