Tri-hexagonal problem

This has been the only problem I’ve truly been stuck on. For those who browse this thread, I already assume you know the problem, if not just look in the Easy section.

Call me a bad coder but I cannot find any other way to analyze and move the hexagons where they need to be by having the amount of possible vertice combinations (though the pattern may not stick to one state of hexagons, but can be applied if when rotated it reflects the same pattern if turned back).

Now this problem has a very small success rate and about 0.2% of the total amount of people who did the most popular Easy problem one did this one. Goes to show how difficult it is for being an ‘easy’ problem.

Share your tips for those who are stuck.

Problem code : N4

I’ll try to give you some hints :

  • How can you represent a game state ? Find an easy (i mean really easy) way to do that.
  • How many valid game states are there ? Is it big ?
  • In what kind of structure can you represent the game states AND transitions from one step to another ?
  • Is it easy to write a function to implement the transitions, assuming you can generate states ?
  • If you generate all states, how would you then answer the given queries ? Is it fast enough ?

Hope it helps !