I am trying to solve the following problem with linq (already solved this with normal programming):
http://projecteuler.net/problem=43
I currently have the following:
class Program { static void Main(string[] args) { var range0 = Enumerable.Range(0, 3); var range1 = Enumerable.Range(0, 3); var range2 = Enumerable.Range(0, 3); var combo = from val0 in range0 from val1 in range1 from val2 in range2 where (val0 + val1 + val2 == 3) select new { value = val0.ToString() + val1.ToString() + val2.ToString() }; foreach( var value in combo ) { Console.WriteLine(value.value); } Console.ReadLine(); } }
Ultimately, I want to expand this query to accept 9 values, but for now, to my question, how can I check the where clause if each value is different? val0 val1 and val3 must be different.
source share