Random puzzle and brute force search

I have been trying to implement the "random puzzle" function. So far, I have two versions of it in my program and both are behaving in a weird manner.

After some investigations I found out that my brute force search function isn't correct actually. It gives the correct solution in some situations but in tough cases where the number of solved cells is low, it doesn't solve the puzzle correctly.

I should mention that there's also the possibility that my function is correct, but I didn't get the correct result because of memory restrictions(from the way I implement the function, quite a lot of memory has to be consumed to hold all the temp variables).

Anyway, I'm currently working on a correctly implemented brute force search and hopefully, in my next version, you'll also see a working "random puzzle" button.