sudoku_solver

Sudoku Solver - Day 5

Looks like this project is done! I plugged the semi-solved Grid 42 into a sudoku app to check for the next step, and immediately saw it: locked intersections. This happens when all of the candidates for a given digit in a box appear in the interesction of that box and a row/column or vice versa. If every cell that could contain a 1 in box 0 is in row 0, you know that the digit 1 can’t appear anywhere else in row 0.

Sudoku Solver - Day 4

WELL turns out I had a glitch in my code. Let’s recap where the last installment left off. My algorithm thought that this was fully solved: 829|31 |475 5 7|489|123 1 4|275|689 ---+---+--- 2 3|64 |9 7 461|927|538 97 |138|246 ---+---+--- 713|852|694 92|764|851 648|3 |7 2 So, that’s a miss. I went back through my code to identify the issue and discovered that there was a bug in my hiddenPairs code.

Sudoku Solver - Day 3

The next order of business was to see how far we could get solving using only naked singles and hidden singles. easy=[ [0,5,0,4,0,9,0,0,2], [4,0,0,6,0,0,0,7,0], [0,0,2,0,0,0,8,0,9], [0,0,0,0,3,0,0,0,7], [0,0,4,0,0,0,3,6,0], [0,0,0,0,2,0,0,0,4], [0,0,3,0,0,0,7,0,5], [1,0,0,3,0,0,0,2,0], [0,4,0,7,0,8,0,0,1]] gr=Grid(easy) gr.solve() 358|479|612 491|682|573 672|153|849 ---+---+--- 816|534|297 524|917|368 739|826|154 ---+---+--- 963|241|785 187|395|426 245|768|931 Score: 0 Sum: 405 Oh, ok. I guess I’ll keep going then. moderate = [ [8,0,0,0,6,0,0,0,3], [0,0,2,0,0,0,4,0,0], [0,3,6,2,0,4,7,8,0], [0,0,1,3,0,7,5,0,0], [4,0,0,0,5,0,0,0,7], [0,0,8,1,0,6,2,0,0], [0,8,9,4,0,1,3,7,0], [0,0,4,0,0,0,8,0,0], [3,0,0,0,7,0,0,0,2]] Grid(moderate).solve() 847|569|123 192|783|456 536|214|789 ---+---+--- 921|347|568 463|852|917 758|196|234 ---+---+--- 689|421|375 274|635|891 315|978|642 Score: 0 Sum: 405 Oh.

Sudoku Solver - Day 2

Today’s work had some ups and downs for sure. Once again, if you want to follow along, you can see my code here: @KendraPendolino/UnlinedSeashellMineral. I started by adding basic elimination for cells in the same group as a solved cell. While there, I realized I had forgotten to put in a reference from the cell back to the grid, so I added that too. class Cell(): ... def setGrid(self,grid): self.grid=grid def solve(self,value): self.

Sudoku Solver - Day 1

I wasn’t able to get as much done today as I’d hoped, but I did get started with it. I’m doing my coding using Replit.com; you can see my code here: @KendraPendolino/UnlinedSeashellMineral. So, let’s see what we have so far. I found a very easy sudoku puzzle to start with. Here it is as a two-dimensional array. test = [ [0,0,6,9,0,1,2,0,0], [0,2,0,3,0,4,0,7,0], [1,0,0,0,7,0,0,0,8], [4,6,0,0,0,0,0,2,5], [0,0,3,0,0,0,7,0,0], [7,9,0,0,0,0,0,6,4], [6,0,0,0,3,0,0,0,7], [0,4,0,2,0,9,0,8,0], [0,0,8,7,0,6,5,0,0]] I made some game-day changes to the setup.

Sudoku Solver - Day 0

I got the idea for this project from Project Euler. If you’re someone who likes tinkering with code and algorithms, I highly recommend checking out Project Euler to add a little something extra to your personal and professional development. Anyway, here’s the project: I want to create a sudoku-solving algorithm. That’s it, really. It’s nothing particularly groundbreaking, but I want to do it for myself and capture my thought process along the way.