public void Cross0By0() { var set1 = new int[0]; var set2 = new int[0]; var set1TimesSet2 = SetOperations <int> .CrossProduct(new[] { set1, set2 }).ToArray(); Assert.AreEqual(0, set1TimesSet2.Length); }
private static IEnumerable <Group> NaiveSolverFull(IEnumerable <Color> colors) { var colourPointsPerColor = from color in colors select color.Points.Select(colorValue => new ColorPoint(colorValue, color)); var groupCandidates = from colorPointCombination in SetOperations <ColorPoint> .CrossProduct(colourPointsPerColor) select new Group(colorPointCombination); return(groupCandidates.Where(IsGroupValid)); }
public void Cross2By3() { var set1 = new[] { 1, 2 }; var set2 = new[] { 7, 8, 9 }; var set1TimesSet2 = SetOperations <int> .CrossProduct(new[] { set1, set2 }).ToArray(); Assert.AreEqual(6, set1TimesSet2.Length); var expected = new[] { new[] { 1, 7 }, new[] { 1, 8 }, new[] { 1, 9 }, new[] { 2, 7 }, new[] { 2, 8 }, new[] { 2, 9 } }; for (int i = 0; i < 6; i++) { CollectionAssert.AreEqual(expected[i], set1TimesSet2[i]); } }