Refactor Sudoku field and solver implementation
This commit is contained in:
@@ -17,13 +17,16 @@ func (ld *LastDigit) SearchProgressableCells() int {
|
||||
missingNumbers := part.GetMissingNumbers()
|
||||
if len(missingNumbers) == 1 {
|
||||
var emptyCell *field.Cell
|
||||
emptyCount := 0
|
||||
part.ForEachCell(func(cell *field.Cell) {
|
||||
if cell.GetNumber() == 0 {
|
||||
emptyCell = cell
|
||||
emptyCount++
|
||||
}
|
||||
})
|
||||
// fmt.Println(part)
|
||||
// fmt.Printf("Gefundene Zelle: %d/%d - %d, missungNumber: %v, Typ: %T\n", emptyCell.Pos.GetRow(), emptyCell.Pos.GetColumn(), emptyCell.GetNumber(), missingNumbers, part)
|
||||
if emptyCount != 1 {
|
||||
return
|
||||
}
|
||||
change := field.ExternalChange{
|
||||
Cell: emptyCell,
|
||||
Action: field.ActionSetNumber,
|
||||
@@ -31,10 +34,9 @@ func (ld *LastDigit) SearchProgressableCells() int {
|
||||
From: emptyCell.GetNumber(),
|
||||
TriggerdBy: ld.getName(),
|
||||
}
|
||||
ld.changes = append(ld.changes, change)
|
||||
ld.queue(change)
|
||||
}
|
||||
})
|
||||
// fmt.Printf("LastDigit Changes %d\n", len(ld.changes))
|
||||
return len(ld.changes)
|
||||
}
|
||||
|
||||
@@ -42,6 +44,10 @@ func (ld *LastDigit) getName() string {
|
||||
return "Last Digit"
|
||||
}
|
||||
|
||||
func (ld *LastDigit) Name() string {
|
||||
return ld.getName()
|
||||
}
|
||||
|
||||
// ────────────────────────────────────────────────────────────────────────────── //
|
||||
// CRP STRUCTURE //
|
||||
// ────────────────────────────────────────────────────────────────────────────── //
|
||||
|
||||
Reference in New Issue
Block a user