using System.Collections.Generic;
public static void Main()
Dictionary<string, byte[][]> dicCombinations = new Dictionary<string, byte[][]>
{ "2,3",new byte[][] { new byte[] { 1,2 },new byte[] { 1,3 },new byte[] { 2,3 } } }
,{ "2,4",new byte[][] { new byte[] { 1,2,3 },new byte[] { 1,2,4 },new byte[] { 1,3,4 },new byte[] { 2,3,4 } } }
,{ "2,5",new byte[][] { new byte[] { 1,2,3,4 },new byte[] { 1,2,3,5 },new byte[] { 1,2,4,5 },new byte[] { 1,3,4,5 },new byte[] { 2,3,4,5 } } }
,{ "2,6",new byte[][] { new byte[] { 1,2,3,4,5 },new byte[] { 1,2,3,4,6 },new byte[] { 1,2,3,5,6 },new byte[] { 1,2,4,5,6 },new byte[] { 1,3,4,5,6 },new byte[] { 2,3,4,5,6 } } }
,{ "3,4",new byte[][] { new byte[] { 1,2 },new byte[] { 1,3 },new byte[] { 1,4 },new byte[] { 2,3 },new byte[] { 2,4 },new byte[] { 3,4 } } }
,{ "3,5",new byte[][] { new byte[] { 1,2,3 },new byte[] { 1,2,4 },new byte[] { 1,2,5 },new byte[] { 1,3,4 },new byte[] { 1,3,5 },new byte[] { 1,4,5 },new byte[] { 2,3,4 },new byte[] { 2,3,5 },new byte[] { 2,4,5 },new byte[] { 3,4,5 } } }
,{ "3,6",new byte[][] { new byte[] { 1,2,3,4 },new byte[] { 1,2,3,5 },new byte[] { 1,2,3,6 },new byte[] { 1,2,4,5 },new byte[] { 1,2,4,6 },new byte[] { 1,2,5,6 },new byte[] { 1,3,4,5 },new byte[] { 1,3,4,6 },new byte[] { 1,3,5,6 },new byte[] { 1,4,5,6 },new byte[] { 2,3,4,5 },new byte[] { 2,3,4,6 },new byte[] { 2,3,5,6 },new byte[] { 2,4,5,6 },new byte[] { 3,4,5,6 } } }
,{ "4,5",new byte[][] { new byte[] { 1,2 },new byte[] { 1,3 },new byte[] { 1,4 },new byte[] { 1,5 },new byte[] { 2,3 },new byte[] { 2,4 },new byte[] { 2,5 },new byte[] { 3,4 },new byte[] { 3,5 },new byte[] { 4,5 } } }
,{ "4,6",new byte[][] { new byte[] { 1,2,3 },new byte[] { 1,2,4 },new byte[] { 1,2,5 },new byte[] { 1,2,6 },new byte[] { 1,3,4 },new byte[] { 1,3,5 },new byte[] { 1,3,6 },new byte[] { 1,4,5 },new byte[] { 1,4,6 },new byte[] { 1,5,6 },new byte[] { 2,3,4 },new byte[] { 2,3,5 },new byte[] { 2,3,6 },new byte[] { 2,4,5 },new byte[] { 2,4,6 },new byte[] { 2,5,6 },new byte[] { 3,4,5 },new byte[] { 3,4,6 },new byte[] { 3,5,6 },new byte[] { 4,5,6 } } }
,{ "5,6",new byte[][] { new byte[] { 1,2 },new byte[] { 1,3 },new byte[] { 1,4 },new byte[] { 1,5 },new byte[] { 1,6 },new byte[] { 2,3 },new byte[] { 2,4 },new byte[] { 2,5 },new byte[] { 2,6 },new byte[] { 3,4 },new byte[] { 3,5 },new byte[] { 3,6 },new byte[] { 4,5 },new byte[] { 4,6 },new byte[] { 5,6 } } }
double[] values = new double[6];
Console.WriteLine(AverageFunction(1,6,dicCombinations,values).ToString());
public static void PrintCombinations(byte[][] combinations)
string ret = string.Empty;
for(byte row = 0; row < combinations.Length; row++)
if (row != 0) ret = ret + Environment.NewLine + "n";
for(byte col = 0; col < combinations[row].Length; col++)
if (col != 0) ret = ret + ",";
ret = ret + combinations[row][col].ToString();
public static double AverageFunction(byte M, byte N, Dictionary<string, byte[][]> dicCombinations, double[] values)
if (values.Length == values.Distinct().Count())
byte R = (byte)((N - M) + 1);
combinations = new byte[1][];
combinations[0] = new byte[N];
for (byte col = 0; col < N; col++)
combinations[0][col] = col;
PrintCombinations(combinations);