public void CounterOf5_5_5() { var counter = new CompoundCounter(5, 5, 5, 5); counter.TotalCombinations.Should().Be(625); PrintAll(counter); }
public void CounterOf1_1() { var counter = new CompoundCounter(1, 1); counter.TotalCombinations.Should().Be(1); PrintAll(counter); }
public void CounterOf2_2_2() { var counter = new CompoundCounter(2, 2, 2); counter.TotalCombinations.Should().Be(8); PrintAll(counter); }
public void PrintAll(CompoundCounter counter) { Console.WriteLine(counter); while (counter.Increment()) { Console.WriteLine(counter); } }
public static IList <IList <string> > Enumerate(params IList <string>[] inputLists) { var maximums = inputLists.Select(z => z.Count); var counter = new CompoundCounter(maximums); if (counter.TotalCombinations == 0) { return(new List <IList <string> >()); } var result = (IList <IList <string> >) new List <IList <string> >(); do { var currentIndices = counter.Current; var currentValue = (IList <string>)currentIndices.Select((i, listIndex) => inputLists[listIndex][i]).ToList(); result.Add(currentValue); } while (counter.Increment()); return(result); }