DEV Community


Discussion on: Critique My Code: Sudoku Solver in Go

chuck_ha profile image
Chuck Ha

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!