How to Generate a -complete- sudoku board? algorithm error

前端 未结 6 1203
情话喂你
情话喂你 2020-12-31 17:35

I\'m trying to generate a complete (ie, each cell filled with a number) Sudoku-like board. It\'s for something else that has nothing to do with sudokus, so I am not interest

6条回答
  •  醉酒成梦
    2020-12-31 18:13

    Start out with a solved Sudoko like this:

    ABC DEF GHI
    329 657 841 A
    745 831 296 B
    618 249 375 C
    
    193 468 527 D
    276 195 483 E
    854 372 619 F
    
    432 716 958 G 
    587 923 164 H 
    961 584 732 I
    

    And then permutate it by switching columns and switching rows. If you only switch within the following groups ABC, DEF, GHI, the Sudoku is still solved.

    A permutated version (switching columns):

    BCA DFE IGH   
    293 675 184 A 
    457 813 629 B 
    186 294 537 C 
    
    931 486 752 D 
    762 159 348 E 
    548 327 961 F 
    
    324 761 895 G 
    875 932 416 H 
    619 548 273 I 
    

    And after some more permutation (switching rows):

    BCA DFE IGH   
    293 675 184 A 
    186 294 537 C 
    457 813 629 B 
    
    931 486 752 D 
    548 327 961 F 
    762 159 348 E 
    
    875 932 416 H 
    619 548 273 I 
    324 761 895 G 
    

提交回复
热议问题