算两个集合共有多少种配合

public static bool Do(List<GoodsSkuInfoDetail> goodsSkuInfos, List<List<KeyValue>> param)
{
if (param == null) { return false; }
List<List<KeyValue>> LO = new List<List<KeyValue>>();
int sum = 1;
int n = 0;
foreach (List<KeyValue> o in param)
{
LO.Add(o);
sum *= o.Count;
n++;
};
for (int i = 0; i < sum; i++)
{
List<KeyValue> _o = new List<KeyValue>();
for (int j = 0; j < n; j++)
{
List<KeyValue> o = LO[j];
_o.Add(o[(i * Index(LO, j) / sum) % o.Count]) ;
}
var skuinfo = goodsSkuInfos.Where(x => x.GoodsAttributeList == _o);
}
return true;
}

private static int Index(List<List<KeyValue>> LO, int lindex)
{
int n = 1;
for (int i = 0; i < LO.Count; i++)
{
if (i <= lindex)
{
n = n * LO[i].Count;
}
else
{
break;
}
}
return n;
}

posted on 2020-11-16 16:23  程铭  阅读(107)  评论(0编辑  收藏  举报