If you're not really into math related problems or discussions this thread may not be for you - unless you want to learn about math in Sudoku.Introduction
One day I got a message from a friend of mine. He talked to me about Sudoku and he said I couldn't beat him in that game. I took it as a challenge.
I started to play it every single day and now I can solve the most hardest Sudoku I've found on newspaper. I know I'm not the only one who is capable to do so but at least I beat my friend. he wasn't very happy about it so he thought to push it a little further. Few weeks later he called me again and said ".. now I understand how Sudoku tables are created!". I asked him can you create one from out of nothing? He mumbled.
I said to him I could give it a try. He suggested that if I can't create a valid Sudoku table generator in 5 days I'd have to offer him a night in a bar. However if I manage to do so he won't question my capability to solve math related problems.
It took me 2 days (11 hours of coding, to be precise ..) to create a valid Sudoku table generator. That wasn't enough for me, though. I wanted to make the code much shorter and faster. That's why I spend another 2 days to make it even better.
I have to admit I'm more then surprised of what I achieved. I tried a lot of different methods I could think of and the results were... Well, amazing.How fast it is?
First of all I'd like to make one thing clear. The thing was not to create a Sudoku game. The whole idea was to create a valid Sudoku table. So basically that means it's kind of a already-solved Sudoku.
The code itself is only about 60 lines long - or should I stay short
- and it creates a valid Sudoku table immediately. I did almost 100 tests to create 1,000 valid Sudoku tables
Guess how many seconds it took? Approximately 5 seconds
each time. That means it takes 0,005 seconds to create one. Impressive, huh?What's next?
There are several different methods how a valid Sudoku table can be created and I will write a short guide on one of them - the one I used.
This thread will hold a several posts because I don't have time to explain it all in one post. So be patient and stay tunes.