using System.Collections.Generic;
public static void Main()
var results = new List<List<double>>();
var set = new double[] { 1, 2, -3 };
GetCombinations(set.Where(x => x > 0).ToArray(), results);
results.Add(set.Where(x => x > 0).ToList());
var negatives = set.Where(x => x < 0).ToList();
foreach (var negative in negatives)
var matches = results.Where(x => x.Sum(t => t) == -negative).ToList();
foreach (var match in matches)
Console.WriteLine(string.Join(" + ", match) + " = " + negative);
private static void GetCombinations<T>(T[] set, List<List<T>> result)
for (int i = 0; i < set.Length; i++)
var temp = new List<T>(set.Where((s, index) => index != i));
if (temp.Count > 0 && !result.Where(l => l.Count == temp.Count).Any(l => l.SequenceEqual(temp)))
GetCombinations<T>(temp.ToArray(), result);