Correct data structure for Sudoku puzzle presentation?

What intelligent data structure can I use to create Sudoku puzzles? That is, 9X9 square, where each "cell" contains either a number or a space.

Special considerations include:

  • Ability to compare between rows, columns and 3X3 groups
  • Ease of implementation (particularly in Python)
  • Efficiency (not paramount)

I believe a 2D array can work in two slots, but this seems like a less elegant solution. I just wanted to know if there is a better data structure.

+5
source share
4 answers

, , , , 2D-. .

, .

, -.

, "" . , : -)


, , /.

, , , , , :

  • , .
  • ( -) , .
  • N N //- , .
  • //- , ( ), //- .

, , .

:

123 456 789
456 789 123
789 123 456

234 567 891
567 891 234
891 234 567

345 678 912
678 912 345
912 345 678

( 500) , . , , (, 1, 2 3 , 4, 5 6).

, .

. ​​ , . , , .

, .

, , , . , .

, , , , .

, , .

, , : -)

+10

. , , , , Python .

+6

2D-.

, 2D- (, " X", ( , - ).

2D- (, 2 ), 81 , * 9 + j. , .

1D , 2D-. (dunno, Python), .

+2

Python . , , 2D- .

You can learn more about python data types here .

0
source

All Articles