PDA

View Full Version : Sudoku



Celestial
01-23-2013, 03:57 AM
So I've been porting my PHP Sudoku script to C# and just came across an issue。。。

It would never generate the full puzzle...

After about an hour of running in circles, I found the answer...


public int[] getBox(int x, int y) {
x = 5;

It's always the simplest things that get me stuck for the longest periods of time.
Must remember to remove test variables.

The good news...


{1, 2, 3, 4, 5, 6, 7, 8, 9}
{8, 7, 5, 9, 2, 3, 1, 6, 4}
{6, 9, 4, 7, 8, 1, 5, 3, 2}
{4, 5, 9, 1, 6, 7, 8, 2, 3}
{3, 8, 2, 5, 9, 4, 6, 7, 1}
{7, 6, 1, 2, 3, 8, 4, 9, 5}
{2, 1, 7, 8, 4, 9, 3, 5, 6}
{5, 4, 6, 3, 7, 2, 9, 1, 8}
{9, 3, 8, 6, 1, 5, 2, 4, 7}

Now with a 0.3% generation success rate.