Files
Sudoku/logic/strategies/divers.go
T

66 lines
2.6 KiB
Go

package strategies
import (
"git.kleiax.de/homepage/field"
)
// ────────────────────────────────────────────────────────────────────────────── //
// LAST_DIGIT STRUCTURE //
// ────────────────────────────────────────────────────────────────────────────── //
type LastDigit struct {
Base
}
func (ld *LastDigit) SearchProgressableCells() int {
ld.field.ForEachPart(func(part field.Part) {
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++
}
})
if emptyCount != 1 {
return
}
change := field.ExternalChange{
Cell: emptyCell,
Action: field.ActionSetNumber,
Value: missingNumbers[0],
From: emptyCell.GetNumber(),
TriggerdBy: ld.getName(),
}
ld.queue(change)
}
})
return len(ld.changes)
}
func (ld *LastDigit) getName() string {
return "Last Digit"
}
func (ld *LastDigit) Name() string {
return ld.getName()
}
// ────────────────────────────────────────────────────────────────────────────── //
// CRP STRUCTURE //
// ────────────────────────────────────────────────────────────────────────────── //
type CRP struct {
Base
}
// ────────────────────────────────────────────────────────────────────────────── //
// SIMPLE_COLORING_T1 STRUCTURE //
// ────────────────────────────────────────────────────────────────────────────── //
type SimpleColoringT1 struct {
Base
}