GLneo wrote:but what if I want to test 3, 4, 5+ numbers?
I'm not really sure....Getting two digits to work in such a small amount of code was kind of hackish by itself. In fact, I'm not entirely sure how isin works... I'm thinking of two ways at the moment for multiples:
Expand the table array. This could get ugly for 7 some numbers...
Check by trying different combinations of the numbers and calling isin multiple times. Something like:
static int[] NotSummable(int[] originals, int limit)
{
List<int> l = new List<int>(originals);
List<int> ret = new List<int>();
for (int i = 1; i < limit; i++)
{
bool found = false;
foreach (int orig in l)
{
if (l.Contains(i - orig) || l.Contains(i))
{
l.Add(i);
found = true;
break;
}
}
if (!found)
ret.Add(i);
}
return ret.ToArray();
}