![]() | A Minor Sudoku Improvement |
|
06 Feb 2011, 05:57
Evan Clark (1 post) |
Here are some changes I made to the Sudoku app to prevent one of the originally given numbers from being changed or deleted. It’s not a big deal but someone might accidentally do that and cause the whole puzzle to become unsolvable. In the method “private int[] getPuzzle(int diff)” I also changed the “showKeypadOrError” method (lines I added are denoted by ~~)
All this does is make it so the keypad box does not pop up on one of the numbers originally given. |
|
07 Feb 2011, 14:41
Ed Burnette (1316 posts) |
Looks good. Marshal Farrier has been working on a similar change here: The biggest enhancement that the program needs is to be able to either fetch games from the Internet or make random games. If anybody finds a Sudoku game web service I’d really like to know about it. |
|
15 Feb 2011, 00:15
Austin Warren (13 posts) |
Nice and simple way to accomplish this. The way I managed to do it was to create a function called getStartLocations, which takes the original puzzle as an input. In order for this to work, I created a function that scans the original puzzle for anything thats not a zero, and converts it’s coordinate from the one dimensional puzzle array into a 2 dimensional tile location, X and Y. This way the starting numbers only get computed once, when the new puzzle is created. The showKeypadOrError function then doesnt have to run through the entire puzzle every time. The showKeypadOrError calls my isStartLocation function which scans my array of starting locations and returns a boolean. The only one thing i need to figure out, is that currently my startLocations array is a constant size of [50]. I don’t know how i could make is dynamic to how many start locations there are. Any ideas for this? Not that running through an array of size 81 is very memory intensive, I’m just trying to practice efficient code. Cheers, Austin |
|
15 Feb 2011, 20:29
Austin Warren (13 posts) |
I also just realized that your code will not stop you from changing tiles when using the d-pad, as there is no dialog box when using the d-pad. A way to get around this is to modify the setTileIfValid or whatever its called. All you need to do is make a check in there, if(isStartTile(x,y))
return false; |
| You must be logged in to comment |

