A nice easy project

I thought it would be a fun and interesting exercise in programming – to generate a Sudoku game (not solve) programmatically. I started with PHP. All plain sailing until it started looking difficult. If you haven’t tried it, just try create a completed sodoku grid (see http://www.sudokufun.com if you have no idea what I’m talking about). To my horror I realised that it was quite easy to start filling in a grid but then find you are stuck a few rows from the end.

The solution seemed to be processing brute force: start adding random numbers 1 square at a time – starting from the top, reading left to right. With eah number that you add to the grid, you check the vertical and horizonal and local box for dupilcates – if all clear then add the number. Use a 2D array to place the results in. Easy peesey lemon sequeesy. Er no. After one aborted attempt in php, followed by a second php rewrite I had to give up as php get all funny about declared arrays. Things made worse by trying to pass lists of numbers and exploding them to arrays. Real mess.

So re-write 3. This time in C# using Visual Studio. I’d not done anything in C#, just a little Java, so  it was a learning process. This evening on the train home I sat staring at the laptop trying figure it out and not getting far. I’d ditched the lists and just passed arrays about which simplified things. But I could bear it any longer and decided to go online and see how others were doing it. That’s when I realised I taken on a fairly serious project – forums full of programming super-brains all trying to figure out a way of doing it. OK, I admit they were after a high-speed solution that generates genuine unique grids or something. And it was in C++ and things. The solutions are out there but I’ve no more change of pinching someone else’s solution that I have of solving it myself – which I shall do. Just give me time.

Once acheived, and a good number of puzzles “banked” then I’m going to build the Big Idea. Can’t tell any more a the mo’ but if you’re a sudoku fiend then this is then next step….

By the way, I’ve only ever completed 1 sudoku puzzle and that was enough thanks, I prefer my pocket computer chess.


About this entry