

I claim that if solution exists, it can obtained by removing this pair first.ī)If all tiles of one type can be matched now(even if there are more than 2 of them), match them. Do not try to remove any other pairs in this state.

However, there are a few heuristic to speed up the search:Ī)If there are only two tiles of one type and they can be removed, remove them. Otherwise, you can use, let's say, depth first search to find the pairs of matching tiles.Ī naive solution would be to try to match every pair, remove it and keep searching(and do backtracking if this branch fails). If no tiles are left, the solution is found. 1)Let's use backtracking with some heuristics(I don't know how fast it would actually work).Ģ)Let's assume that the the current state is S(state is defined by the tiles which are left).
