Skip to main content

An Object Oriented Sudoku Game Generator

Project description

Beginner Object Oriented Sudoku Board Generator

Matrix Class

This class keeps track of the board with an instance variable called self.board It is responsible for checking the rules of sudoku in order to make a move, it check to see which numbers to exclude from a cell's row, column and 3x3 square

The variable self.cellStack is a list of the last 5 cells that were changed in order to backtrack in case of the algorithm cornering itself

Finally, self.cells is just a flattened version of self.board for easy traversing.

Cell Class

Each Cell gets initialized with 4 instance variables:

  • self.row and self.col keep track of cell's position in the board
  • self.options contains all the possible numbers that the cell could be
  • self.num is the actual number it contains

Main

The main function of the program is an example of how to create a board

  • Create a Matrix Object
  • Set the center cell (located at 4,4) to a random number utilizing Matrix.changeBoard(self, cell:Cell)
    • Parameter cell is retrieved from using Matrix.self.board[4][4]
  • Start a while loop that runs if Matrix.cells contains anything
  • Get least number of choices of cell closest to being solved
    • Important to mention that each time Matrix.changeBoard() is called, it sorts self.cells to have the cells closest to being done in front
  • Create a list of all cells that have least number amount of choices
  • Randomly choose one cell from this list
  • Call Matrix.changeBoard() with the random cell as the argument

End

To use this module all you have to do is set var_name = sudoku-oop.generateBoard() and it will return a Matrix Object with your board

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

Sudoku-DCHEQUER-0.0.5.tar.gz (5.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

Sudoku_DCHEQUER-0.0.5-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

Details for the file Sudoku-DCHEQUER-0.0.5.tar.gz.

File metadata

  • Download URL: Sudoku-DCHEQUER-0.0.5.tar.gz
  • Upload date:
  • Size: 5.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.0 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10

File hashes

Hashes for Sudoku-DCHEQUER-0.0.5.tar.gz
Algorithm Hash digest
SHA256 c88d776cc0819c9e5a375b4b172f722e23f45b91f5df28540639cbd922aaf7bf
MD5 26312a80b16721ed2fdcd2b37ec9cb60
BLAKE2b-256 acc68ed5d7288e83cea392a8502fd4b5fe3cb7ed7fb22c76c28c01c43fd5b457

See more details on using hashes here.

File details

Details for the file Sudoku_DCHEQUER-0.0.5-py3-none-any.whl.

File metadata

  • Download URL: Sudoku_DCHEQUER-0.0.5-py3-none-any.whl
  • Upload date:
  • Size: 5.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.0 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10

File hashes

Hashes for Sudoku_DCHEQUER-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 5e0f41988c5b974e557d14a1462a3f149a175e608b3ba73c5c5329528fdff49f
MD5 ee57247fa5f25c3ba8a04408a21cd192
BLAKE2b-256 33a276964188c56262ade26f1a2f75a36e28c8ce20e7bc4f01c5ae8dc2eecee8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page