Click or drag to resize
Dlx.Solve<TData, TRow, TCol> Method (TData, Func<TData, IEnumerable<TRow>>, Func<TRow, IEnumerable<TCol>>, Func<TCol, Boolean>)
Find all possible solutions to an exact cover problem given an arbitrary data structure representing a matrix and a predicate.

Namespace: DlxLib
Assembly: DlxLib (in DlxLib.dll) Version: 1.3.0.0 (1.3.0.0)
Syntax
public IEnumerable<Solution> Solve<TData, TRow, TCol>(
	TData data,
	Func<TData, IEnumerable<TRow>> iterateRows,
	Func<TRow, IEnumerable<TCol>> iterateCols,
	Func<TCol, bool> predicate
)

Parameters

data
Type: TData
The top-level data structure that represents the exact cover problem.
iterateRows
Type: System.Func<TData, IEnumerable<TRow>>
A System.Func delegate that will be invoked to iterate the rows in the matrix.
iterateCols
Type: System.Func<TRow, IEnumerable<TCol>>
A System.Func delegate that will be invoked to iterate the columns in a particular row in the matrix.
predicate
Type: System.Func<TCol, Boolean>
A predicate which is invoked for each value in the matrix to determine whether the value represents a logical 1 or a logical 0 indicated by returning true or false respectively.

Type Parameters

TData
The type of the data structure that represents the exact cover problem.
TRow
The type of the data structure that represents rows in the matrix.
TCol
The type of the data structure that represents columns in the matrix.

Return Value

Type: IEnumerable<Solution>
Yields Solution objects as they are found.
Examples
var data = new List<Tuple<char[], string>>
    {
        Tuple.Create(new[] {'X', 'O', 'O'}, "Some data associated with row 0"),
        Tuple.Create(new[] {'O', 'X', 'O'}, "Some data associated with row 1"),
        Tuple.Create(new[] {'O', 'O', 'X'}, "Some data associated with row 2")
    };
var dlx = new Dlx();
var solutions = dlx.Solve(data, d => d, r => r.Item1, c => c == 'X');
See Also