Skip to content
Jeyabalaji Subramanian edited this page Jun 21, 2020 · 2 revisions

Welcome to the go-sudoku-solver wiki!

This solver is all about recursion and concurrency!

  1. We start with an unsolved puzzle.
  2. For each empty cell, we find out a set of eligible numbers
  3. Pick a cell with least eligible numbers to start the guesswork
  4. On this cell, create a go routine to call Solve (recursively) passing each eligible number
  5. The step 1 to 4 is repeated once again and so on and so forth

Here's a common pattern for spawning multiple go routines:

chanMyChannel := make(chan Channel)
wg := new(sync.WaitGroup)
// Spawn multiple threads
go func() {
defer wg.Done()
// do work & send the data in channel
}(wg, &chanMyChannel)

// wait for all threads to complete
go func(wg *sync.WaitGroup, c chan Channel) {
  wg.Wait()
  close(c)
}(wg, chanMyChannel)

// collect the results from channel
for r := range chanMyChannel{
 // reduce data
}

Clone this wiki locally