Skip to content

Commit

Permalink
Merge pull request #2 from derek-hoogewerf/GUI
Browse files Browse the repository at this point in the history
Gui
  • Loading branch information
derek-hoogewerf authored Apr 3, 2020
2 parents 29e8d5c + b86d1e3 commit 98d3292
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 52 deletions.
14 changes: 14 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python: Module",
"type": "python",
"request": "launch",
"module": "sudoku-solver"
}
]
}
53 changes: 1 addition & 52 deletions solver.py
Original file line number Diff line number Diff line change
@@ -1,50 +1,4 @@
board = [
[7,8,0,4,0,0,1,2,0],
[6,0,0,0,7,5,0,0,9],
[0,0,0,6,0,1,0,7,8],
[0,0,7,0,4,0,2,6,0],
[0,0,1,0,5,0,9,3,0],
[9,0,4,0,6,0,0,0,5],
[0,7,0,3,0,0,0,1,2],
[1,2,0,0,0,7,4,0,0],
[0,4,9,2,0,6,0,0,7]
]

def print_board(bo):
for i in range(len(bo)):
if i % 3 == 0 and i != 0:
print("- - - - - - - - - - - - - ")

for j in range(len(bo[0])):
if j % 3 == 0 and j != 0:
print(" | ", end="")

if j == 8:
print(bo[i][j])
else:
print(str(bo[i][j]) + " ", end="")


def find_empty(bo):
for i in range(len(bo)):
for j in range(len(bo[0])):
if bo[i][j] == 0:
return (i, j) # row, col

return None

board = [
[0,0,0,0,3,0,0,0,0],
[0,6,5,0,1,0,4,7,0],
[8,3,0,0,0,0,0,6,9],
[0,0,2,3,9,5,8,0,0],
[0,0,1,0,0,0,6,0,0],
[0,0,3,6,4,1,5,0,0],
[4,2,0,0,0,0,0,5,1],
[0,7,9,0,5,0,3,2,0],
[0,0,0,0,2,0,0,0,0]
]

# solver.py

def solve(bo):
find = find_empty(bo)
Expand Down Expand Up @@ -110,8 +64,3 @@ def find_empty(bo):
return (i, j) # row, col

return None

print_board(board)
solve(board)
print("___________________")
print_board(board)

0 comments on commit 98d3292

Please sign in to comment.