I came across a puzzle a few days ago. It's solvable easily by hand. But I was trying to build an algorithm for solving it. But i dont know how I should proceed.
Here you can see that i have to connect all pairs of colored dots. For example i need to connect yellow dot to another yellow dot, green to other green, blue to blue and so on.
Here is an example of how it should be solved. if the description was not clear.
So you can see that i connected yellow dot with another yellow dot. And blue with another blue. But this causes a problem. I've blocked the path of aqua color as you can see. I hope you get the idea.
So i want to solve it. Brute force approach would work but it will take a long time and i'm not interested in that. I tried about implementing Breadth First Search, Depth First Search, and Dijkstra algorithm. But i think they won't be good in this case. Correct me please if I'm wrong. A* Search may work, but what will be the heuristic?
Can anyone give me some intuition on how to solve the problem?