本文整理汇总了C#中Permutation.Add方法的典型用法代码示例。如果您正苦于以下问题:C# Permutation.Add方法的具体用法?C# Permutation.Add怎么用?C# Permutation.Add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Permutation
的用法示例。
在下文中一共展示了Permutation.Add方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FindUnusableNumbersForMultiDimensionalCageNeighbours
Step FindUnusableNumbersForMultiDimensionalCageNeighbours()
{
Step stepAction = new Step();
foreach (var cage in _kenKenGrid.MultidimensionalCages)
{
List<Permutation> validPerms = FindValidPermutationsForCagePossibilities(cage);
foreach(var val in Enum.GetValues(typeof(Dimension)))
{
Dimension dimension = (Dimension)val;
int minIndex = dimension == Dimension.Row ? cage.Cells.Min(cell => cell.Row) : cage.Cells.Min(cell => cell.Column);
int maxIndex = dimension == Dimension.Row ? cage.Cells.Max(cell => cell.Row) : cage.Cells.Max(cell => cell.Column);
for (int index = minIndex; index <= maxIndex; index++)
{
List<Cell> cageCellsInADimension = null;
if (dimension == Dimension.Row)
{
cageCellsInADimension = cage.Row(index);
}
else if (dimension == Dimension.Column)
{
cageCellsInADimension = cage.Column(index);
}
if (cageCellsInADimension.Count > 1)
{
List<Permutation> allSemiPermutations = new List<Permutation>();
foreach (var perm in validPerms)
{
Permutation semiPerms = new Permutation();
cageCellsInADimension.ForEach(cell => semiPerms.Add(perm[cell.Index]));
allSemiPermutations.Add(semiPerms);
}
List<int> commonNumbers = allSemiPermutations.CommonNumbers();
if (commonNumbers.Count > 0)
{
List<Cell> cageNeighbours = null;
if (dimension == Dimension.Row)
{
cageNeighbours = _kenKenGrid.Row(cageCellsInADimension[0].Row).FindAll(cell => !cage.Cells.Contains(cell));
}
else if (dimension == Dimension.Column)
{
cageNeighbours = _kenKenGrid.Column(cageCellsInADimension[0].Column).FindAll(cell => !cage.Cells.Contains(cell));
}
List<Cell> affectedCells = cageNeighbours.FindAll(cell => !cell.Solved &&
commonNumbers.Any(no => cell.PossibleValues.Contains(no)));
if (affectedCells.Count > 0)
{
stepAction.AffectedNeighboursCells = affectedCells;
stepAction.Dimension = dimension;
stepAction.FoundCell = affectedCells[0];
stepAction.FoundCageCells = cageCellsInADimension;
stepAction.DimensionIndex = index;
stepAction.InvalidNeighbours = cageNeighbours;
stepAction.InvalidNeighbourNumbers = commonNumbers;
return stepAction;
}
}
}
}
}
}
return stepAction;
}