From c62b398c55999c9bb0da6c36d0929be0c0421075 Mon Sep 17 00:00:00 2001 From: sam-ayo Date: Tue, 23 Jan 2024 18:02:03 -0330 Subject: [PATCH 1/2] working sudoku algorithm --- sudoku.go | 63 +++++++++++++++++++++++++++++++++++++++++++++++++- sudoku_test.go | 63 +++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 124 insertions(+), 2 deletions(-) diff --git a/sudoku.go b/sudoku.go index 06ab7d0..0d8910b 100644 --- a/sudoku.go +++ b/sudoku.go @@ -1 +1,62 @@ -package main +package sudoku + + +const BOARD_SIZE = 9 +const SMALL_GRID_SIZE = 3 + + +func isPossible(grid [][]int, row int, col int, n int) bool { + // Check to see if number is unique for row and column + for i:=0; i Date: Tue, 23 Jan 2024 18:33:36 -0330 Subject: [PATCH 2/2] commit all changes --- sudoku.go | 27 ++++++++++++++++----------- sudoku_test.go | 50 ++++++++++++++++++++++++++++++++++++++++++++------ 2 files changed, 60 insertions(+), 17 deletions(-) diff --git a/sudoku.go b/sudoku.go index 0d8910b..b653289 100644 --- a/sudoku.go +++ b/sudoku.go @@ -28,24 +28,29 @@ func isPossible(grid [][]int, row int, col int, n int) bool { return true } -func isSolved(grid [][]int, row int, col int) bool { - // Move along the board - if row == BOARD_SIZE { - row = 0 - if col++; col == BOARD_SIZE { - return true +func findNextEmptyCell(grid [][]int) (int, int, bool) { + for i:=0; i