Nice project! I read through and had a couple of points to share:
Instead of defining Print, define a String() string method on Puzzle. This will implement the standard interface Stringer and you can then fmt.Println(puzzle) and that will call String() on the puzzle struct.
Instead of having a debug field consider implementing a logger with a Debug function and remove the debug field from the Puzzle
Since this isn't a main package I'd expect it to be an importable library complete with godocs on exported types. I think this is good reading.
I didn't spend too long figuring it out, but I'm guessing the runtime is quite high. Probably will never matter on a 9x9 sudoku grid, but what happens when you move to base 16 and have a 15x15 sudoku grid?:) This question is mostly food for thought, nothing really actionable here unless you were interested in calculating the runtime and trying to optimize.
Read more go code! Try reading the standard library for good patterns to follow!
Also I applaud you for sharing your code and asking for feedback. That is not easy to do!
We're a place where coders share, stay up-to-date and grow their careers.
Nice project! I read through and had a couple of points to share:
Instead of defining
Print
, define aString() string
method on Puzzle. This will implement the standard interface Stringer and you can thenfmt.Println(puzzle)
and that will call String() on the puzzle struct.Instead of having a
debug
field consider implementing a logger with aDebug
function and remove the debug field from thePuzzle
Since this isn't a
main
package I'd expect it to be an importable library complete with godocs on exported types. I think this is good reading.I didn't spend too long figuring it out, but I'm guessing the runtime is quite high. Probably will never matter on a 9x9 sudoku grid, but what happens when you move to base 16 and have a 15x15 sudoku grid?:) This question is mostly food for thought, nothing really actionable here unless you were interested in calculating the runtime and trying to optimize.
Read more go code! Try reading the standard library for good patterns to follow!
Also I applaud you for sharing your code and asking for feedback. That is not easy to do!