I know what that part of the code if for. Anyway, I found a VERY complex algorithm to find if the puzzle can be solved. I'll help you implement it into your program.