score:1

here is my take :

var numlist = new list<int> { 12, 33, 24, 63, 45, 32, 3, 18, 22, 7, 10 };

var answers = (from a in numlist
               from b in numlist where a >= b 
               from c in numlist where b >= c 
               from d in numlist where c >= d
               select new { sum = a + b + c + d, ans = "{" + a  + " " + b + " " + c + " " + d + "}"} into temp
               where temp.sum > 100
               select temp.ans).distinct() ;

foreach (var answer in answers)
    console.writeline(answer);

output is truncated (148 total):

{33 32 24 12}
{33 32 24 18}
{33 32 24 22}
{33 32 22 18}
{63 33 12 3}
{63 33 12 7}
{63 33 12 10}
{63 33 24 12}
{63 33 24 3}
{63 33 24 18}
{63 33 24 22}
{63 33 24 7}
{63 33 24 10}
{63 33 32 12}
{63 33 32 24}
{63 33 32 3}
{63 33 32 18}
{63 33 32 22}
{63 33 32 7}
{63 33 32 10}
{63 33 18 12}
{63 33 18 3}
{63 33 18 7}
{63 33 18 10}
{63 33 22 12}
{63 33 22 3}
{63 33 22 18}
{63 33 22 7}
{63 33 22 10}
{63 33 7 3}
{63 33 10 3}
{63 33 10 7}
{63 24 12 3}
{63 24 12 7}
{63 24 12 10}
{63 24 18 12}
{63 24 18 3}

score:3

probably this is not an effient way but it should work:

var numlist = new list<int>() { 12, 33, 24, 63, 45, 32, 3, 18, 22, 7, 10 };

/* get all combinations including duplicates like: 
12,12,12,12 - 12,12,12,34 - 12,12,12,24  and so on
then put them into an array int[] */

var combinations = from x in numlist
            from y in numlist
            from z in numlist
            from t in numlist
            select new [] {x, y, z, t};

/* eliminate the duplicates (like 12-12-12-12) and 
   filter them based on sum */
var result =  combinations
             .where(x => x.sum() > 100 && x.distinct().count() == x.length);

// get distinct combinations using a custom equality comparer 
var distinctresults = result.distinct(new comparer()).tolist();

public class comparer : iequalitycomparer<int[]>
{
    public bool equals(int[] x, int[] y)
    {
        return x.orderby(a => a).sequenceequal(y.orderby(a => a));
    }

    public int gethashcode(int[] obj)
    {
        return obj.select(x => x.gethashcode()).sum();
    }
}

this use of from clause is called compound from clause which allows you to get combinations easily, you can refer to msdn documentation to see more examples also this article from eric lippert might be helpful.


Related Query

More Query from same tag