Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance SudokuPuzzle with Grid Generation from Given Cells #62

Merged
merged 2 commits into from
Mar 2, 2024

Conversation

teogor
Copy link
Owner

@teogor teogor commented Mar 2, 2024

Introduce Grid Generation from Given Cells

This pull request enhances the SudokuPuzzle class with the capability to generate a grid containing pre-filled given cells:

New Function:

fun SudokuPuzzle.generateGridWithGivens(): List<List<Int>>

Purpose:

  • Generates a grid representation of the Sudoku puzzle with the given cells filled in.
  • Constructs a 2D list where each inner list represents a row and each element stores a cell value.
  • Simplifies display or external manipulation of Sudoku puzzles with pre-filled values.

Functionality:

  1. Retrieves the grid size based on the sudokuType.uniqueDigitsCount.
  2. Initializes a mutable 2D list to hold the grid values, initially filled with zeros.
  3. Iterates through the givens collection.
  4. For each given, assigns its value to the corresponding grid cell using its row and col coordinates.
  5. Returns the completed grid as a read-only list of lists.

Benefits:

  • Improved Flexibility: Enables working with Sudoku puzzles in a grid-like format with given cells.
  • Simplified UI Display: Facilitates visual representation of Sudoku puzzles with pre-filled values.
  • External Manipulation: Supports processing or solving Sudoku puzzles with givens using grid-based logic.

@teogor teogor added @enhancement New feature or request @priority-low labels Mar 2, 2024
@teogor teogor added this to the 1.0.0-beta02 milestone Mar 2, 2024
@teogor teogor self-assigned this Mar 2, 2024
@teogor teogor merged commit 15f8137 into main Mar 2, 2024
4 checks passed
@zeobot zeobot bot deleted the enhancement/generate-grid-with-givens branch March 2, 2024 12:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@enhancement New feature or request @priority-low
Projects
Development

Successfully merging this pull request may close these issues.

None yet

1 participant