//public methods public BitArray SolveNonogram(int[][] rows, int[][] cols) { var length = rows.Length * cols.Length; var solutions = CollectionExt.Booleans.Backtrack( new NonogramState(new int[cols.Length], ArrayExt.Create(cols.Length, -1), 0, -1, new BitArray(length), 0), (state, b, i) => state.AssignValue(rows, cols, b), state => state.Position == length); solutions.AppendConstraint(state => b => state.TestValue(rows, cols, b)); return(solutions.SelectResults(set => set.Table).First()); }