Tri-colouring a triangular grid
I checked my old code. I could not fully understand it. I roughly understood that I was struggling with two different orientations of the triangles. But the run time is not too bad, 28ms.
I read the discussion today. I found that there was an easier way to solve the problem without considering too much about the orientations. The code is simple, easier to implement. But the only bad thing is that it took 0.6 second to get the answer.
But Robert_Gerbicz provided an ingenious way to solve the problem! (At least I found the algorithm in his post). It is much more efficient than his first approach. It is equivalent to use two different dynamic programmings in one problem.
I recommend everyone to read his post and figure out how his algorithm works. It is brilliant!
No comments:
Post a Comment