Skip to content

Added backtracking (sudoku)#205

Merged
itsvinayak merged 2 commits intoTheAlgorithms:masterfrom
ruppysuppy:sudoku
Jun 26, 2020
Merged

Added backtracking (sudoku)#205
itsvinayak merged 2 commits intoTheAlgorithms:masterfrom
ruppysuppy:sudoku

Conversation

@ruppysuppy
Copy link
Copy Markdown
Member

Welcome to JavaScript community

Describe your change:

  • Add an algorithm?
  • Fix a bug or typo in an existing algorithm?
  • Documentation change?

Checklist:

  • I have read CONTRIBUTING.md.
  • This pull request is all my own work -- I have not plagiarized.
  • I know that pull requests will not be merged if they fail the automated tests.
  • This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms.
  • All new JavaScript files are placed inside an existing directory.
  • All filenames should use the UpperCamelCase (PascalCase) style. There should be no spaces in filenames.
    Example:UserProfile.js is allowed but userprofile.js,Userprofile.js,user-Profile.js,userProfile.js are not
  • All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation.
  • If this pull request resolves one or more open issues then the commit message contains Fixes: #{$ISSUE_NO}.

Comment on lines +55 to +60
for (let i = 0; i < 9; i++) {
if (i % 3 === 0 && i !== 0) console.log('- - - - - - - - - - - -')
const part1 = board[i].slice(0, 3)
const part2 = board[i].slice(3, 6)
const part3 = board[i].slice(6, 9)
console.log(...part1, ' | ', ...part2, ' | ', ...part3)
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Is this acceptable or I should have directly used the sliced parts in the spread operation?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@ruppysuppy , here we are repeating code, what about creating a function that will take a board with indexes, and return part1
so we can do something like

console.log(Slice(board[i],0,3),' | ', .....)

Copy link
Copy Markdown
Member

@itsvinayak itsvinayak left a comment

Choose a reason for hiding this comment

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

as we are passing board everywhere, what about creating classes. we use ES6 which introduced classes.
it will be a good idea to use classes


class Sudoku {
  constructor(board) {
    this.board = board
  }
}

Copy link
Copy Markdown
Member

@itsvinayak itsvinayak left a comment

Choose a reason for hiding this comment

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

really looks good,
thank you @ruppysuppy

@itsvinayak itsvinayak merged commit a70dfe9 into TheAlgorithms:master Jun 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants