プレイ日記
Does anyone know how to generate random sudoku puzzles? I tried researching it, but I couldn't fing anything useful.
3そうだね
プレイ済み
返信[1]
親投稿
klonoa hellkolbod
if you know how to randomly generated numbers i'm pretty sure its the same concept but you know in squadraints rather than lines
0そうだね
プレイ済み
返信[2]
親投稿
I've tried before but it takes forever to generate.
1そうだね
プレイ済み
返信[3]
親投稿
I figured out a way to swap certain numbers with others to generate random puzzles!
1そうだね
プレイ済み
返信[4]
親投稿
Stewart segludian1
You want to use recursion. Your base test is to check if you have a complete and valid Soduku grid. If so stop returning true. Next check to see if anything in the grid causes the puzzle to not be a valid soduku grid. If you find a problem return false. Next set up a loop. Randomly choose an available number for the next square. Then call your function. If it returns true you return true. If false
1そうだね
プレイ済み
返信[5]
親投稿
Stewart segludian1
if it returns false undo the number. If you havent tried all available numbers try again with another. Otherwise return false. There are soduku generation resources online but not too many. Think I found a pdf something like puzzles from easy to evil or something like that. I would look for that if you can find it.
1そうだね
プレイ済み
返信[6]
親投稿
SıмΞоп SimeonW
A really clever approach is to have a single, pre-generated sudoku, shuffle each row, then shuffle each column, then shuffle every 3x3 box And then mask each number with a shuffled different number (replace all 5s with 9s, ...) Any its as if you just generated a new one, but its much faster
1そうだね
プレイ済み
返信[7]
親投稿
SıмΞоп SimeonW
And*
0そうだね
プレイ済み
返信[8]
親投稿
SıмΞоп SimeonW
Doing those swaps, however, does have rules, and I think the computation may get out of hand I don't have very much experience with sudoku generation, but I know its one of those gray areas in Computer Science, it has to do with the famous P vs. NP problem.
0そうだね
プレイ済み
返信[9]
親投稿
Funny enough, that's exactly how I made it!
0そうだね
プレイ済み