Skip to content

Added English Tutorial for LOJ-1397: Sudoku Solver #400

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

Merged
merged 4 commits into from
Feb 4, 2023

Conversation

mirzaazwad
Copy link
Contributor

Solution to 1397

Solution to 1397
Copy link
Member

@rebornplusplus rebornplusplus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey, good work. But you need to address a few changes.

The filename should be 1397/en.md. That is, you should write these all up in a file named en.md placed in a folder named 1397.

The PR name should in the following format: "Added English Tutorial for LOJ-1397: Sudoku Solver".

Also, check out the comments I made at various lines of this document.

Update to resolve  issues based on given suggestions
@mirzaazwad mirzaazwad closed this Oct 11, 2022
@mirzaazwad mirzaazwad reopened this Oct 11, 2022
@mirzaazwad mirzaazwad changed the title Create 1397 Added English Tutorial for LOJ-1397: Sudoku Solver Oct 12, 2022
1397/en.md Outdated

To summarise,

In each iteration, we find an empty location. At the empty location, we place a value absent from the same row, box and column, and check if the current state of board can be solved. If it cannot be solved, we place 0 in the empty positions, otherwise we place the appropriate value and finally print the final state of the sudoku matrix.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"we place 0 in the empty positions"

Very specific implementation detail. Just say that, if it cannot be solved, we output so.

1397/en.md Outdated

###### Solution Approach

Firstly we implement a basic sudoku solver with four important points:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

five points

1397/en.md Outdated

2) To solve a sudoku we have to place a number at an empty position denoted by '.' in this question

3) We use the isSafe function here to determine whether it is safe to place a particular number
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whether it is safe to place a particular number

Define here what "safe" means.

1397/en.md Outdated

4) If empty location found, we iterate from 1 to 9 and try to place that number in that empty position, checking whether it is safe to place the value in each iteration

5) If the empty positions are such that the number of values that needs to be placed exceeds 9 for the given set of isSafe conditions which means we can't just place 1 to 9, then we can conclude that the Sudoku is not solvable and the empty positions remain as 0 denoting that it cannot be filled
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the number of values that needs to be placed exceeds 9 for the given set of isSafe conditions which means

Implementation detail. A bit confusing if someone doesn't look at the source code. Simply chop this portion off.

@rebornplusplus rebornplusplus added the inactive Has not been active for some time label Dec 9, 2022
Copy link
Member

@rebornplusplus rebornplusplus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated a few things that the author didn't address, since rest of the things were good.

@rebornplusplus rebornplusplus merged commit 1f7cd15 into lightoj-dev:main Feb 4, 2023
@rebornplusplus rebornplusplus added hacktoberfest-accepted and removed inactive Has not been active for some time labels Feb 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants