Hi there,

I am trying to code a bot that solves sudoku puzzles using sudoku.com. I am using computer vision to extract the sudoku board, and then converting that board into a table, where the bot then solves the puzzle by populating the table. The solved sudoku table is then re-inputted back into the site.

I was hoping for some guidance on the logic. What I have now is an array of numbers 1-9. And a counter variable to loop through the 9 rows. There is a do while counter <= 9, where there is a for each row of the extracted sudoku board table, if row(counter) is empty then for each number in the array (1,2,3,4,5,6,7,8,9) check that the entire row does not contain number 1, if it does contain number 1, check 2, if it doesn’t contain 2, then 2 is a candidate. It then checks for the presence of 2 in the column, and if not in the column, it is still a candidate, next it checks for 2 in the 3x3 box in which the relevant cell (row(counter)) is in. If 2 isn’t available it uses 2. That’s the gist of the logic. However, it could fill in a 2, only to find that there’s another cell further down the grid where 2 is the only acceptable number.

Can someone guide me as to what logic I should be using to solve this? I am trying to make it for a demo. Should the bot input 2 where it’s the only eligible number width ways and then swap the 2 further up the column with a different number ? I.e. retrospective solving of the puzzle.

Any help would be so appreciated.

Thanks.