Initial commit

This commit is contained in:
2026-07-17 22:35:11 +02:00
parent 3121a7d818
commit 1ff0efb557
31 changed files with 895046 additions and 0 deletions
+48
View File
@@ -0,0 +1,48 @@
package main
import (
"fmt"
"io"
"os"
"git.kleiax.de/homepage/libs/sudoku"
)
func main() {
solver := sudoku.Solver{}
solver.Add(&sudoku.LastDigit{})
solver.Add(&sudoku.NakedSingle{})
game, err := sudoku.New(&sudoku.PuzzleBank{}, solver, openFile())
if err != nil {
fmt.Println(err.Error())
os.Exit(1)
}
field := game.GetField()
fmt.Println(field.String())
err = game.Solve()
if err != nil {
fmt.Println(err.Error())
}
field = game.GetField()
fmt.Println(field.String())
}
func openFile() []byte {
file, err := os.Open("libs/sudoku/data/sudoku-exchange-puzzle-bank/easy3.txt")
if err != nil {
fmt.Println("Kann datei nicht öffnen")
os.Exit(3)
}
defer file.Close()
content, err := io.ReadAll(file)
if err != nil {
fmt.Println("Kann Daten nicht extrahieren")
os.Exit(4)
}
return content
}