列表排列所有脑干 [英] List permutation existance

查看:126
本文介绍了列表排列所有脑干的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个列表

 List<PossibleSolutionCapacitors> PossibleSolution = new List<PossibleSolutionCapacitors>(); 

这里是它的类

 class PossibleSolutionCapacitors
    {
        public int CapacitorALocation { get; set; }
        public int CapacitorBLocation { get; set; }
        public int CapacitorCLocation { get; set; }    
    }

我有3个整数

 int A;
 int B;
 int C;

我需要检查,如果A,B的任意组合,C被包含在列表中可能的解决方案

即如果下面是在列表(布尔说真/假就够了)

i.e if the following are in the list (Boolean saying true/false is enough)


  1. A,B,C

  2. A,C,B

  3. B,A,C

  4. 等...

这可能吗?

谢谢
大摩

推荐答案

在保存的解决方案一个变化:

A variation on Save's solution:

var fixedSet = new HashSet<int>(){A,B,C};
bool result = PossibleSolutions.Any(x => fixedSet.SetEquals(
    new[] { x.CapacitorALocation,x.CapacitorBLocation,x.CapacitorCLocation }));

这篇关于列表排列所有脑干的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆