Spandan-Bhattacharya / Solve_it

A website which can give you the solution to many solvable games like sudoku, nonogram, crossword puzzles
https://solve-it-self.vercel.app
MIT License
19 stars 48 forks source link

Added N-Queen Problem Solver #192

Closed Aashi19234 closed 9 months ago

Aashi19234 commented 9 months ago

I have added a N-Queen problem Solver, which aims to place the queens in such a way that no two queens threaten each other.

https://github.com/Spandan-Bhattacharya/Solve_it/assets/140010647/0b8e72d3-a195-4938-ae4f-89c6b0632acd

vercel[bot] commented 9 months ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
solve-it ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 2, 2024 4:42pm
Spandan-Bhattacharya commented 9 months ago

Good try! The solution is almost there, just a minor mistake is keeping from working correctly. The solution does not solve the N queen problem as for a chess board of size 8, 8 queens have to be placed. The error lies in the backtracking part of the solve function, do not use the clearQueens function there to do the backtracking, try undo-ing the placeQueen function to make the backtracking part. Also, try implementing a checker board pattern for the chess board, to simulate an actual chess board. @Aashi19234

Aashi19234 commented 9 months ago

@Spandan-Bhattacharya Thank you for your suggestion, I would make the desired changes and issue the PR.