| Register | FAQ | Calendar | Search | Today's Posts | Mark Forums Read |
|
#61
| |||
| |||
| Jordan Marr wrote: > On Jun 17, 8:48 pm, Kreeg <k...{}sentdotcom.nospam> wrote: >> Jordan Marr wrote: >>> I never posted my solution to Whose Fish, and since my old thread >>> probably has a stigma attached to it, I'll post it here. >> *SNIP the rest of Jordan's code* >> >> I had commented earlier that I'd like to see a linq implementation of >> this problem. Well, in an attempt to salvage this thread at least a >> little bit, I thought I'd give one a try. >> >> I used Jordan's OO implementation as a base, and basically used his >> entity objects without modification (I did end up adding a constructor >> to the Street class). >> >> Jordan's code that I stole so much from can be found here: >> >> http://groups.google.com/group/comp....c3044ff3069baa >> >> I cheated a bit (well, maybe a lot) and just used his IsValid rules to >> do my filtering, and used linq to make some other parts of the code a >> little clearer and more compact, I think. I actually end up liking the >> finished product a fair bit. Maybe I'll try to make it all linq in the >> future, but here's what I have. It's the first Linq that I've done, so >> I may well have missed some obvious things. >> >> On my laptop (a lowly centrino 1.4ghz) this runs in about 3 seconds. >> >> using System; >> using System.Collections.Generic; >> using System.Linq; >> using System.Text; >> using BusinessFramework; >> using Entities; >> >> namespace Whose_Fish >> { >> class LinqProgram >> { >> public void Solve() >> { >> //no cross join in linq AFAIK, so I have to do an inner >> join on 1 == 1 >> var allHouses = from Nationalities n in >> Enum.GetValues(typeof(Nationalities)) >> join HouseColors c in >> Enum.GetValues(typeof(HouseColors)) on 1 equals 1 >> join Drinks d in >> Enum.GetValues(typeof(Drinks)) on 1 equals 1 >> join Pets p in >> Enum.GetValues(typeof(Pets)) on 1 equals 1 >> join Smokes s in >> Enum.GetValues(typeof(Smokes)) on 1 equals 1 >> join int o in new int[]{0,1,2,3,4} on 1 >> equals 1 >> select new House() { Nationality = n, >> HouseColor = c, Drink = d, Order=o, Pet=p, Smoke=s }; >> >> var validHouses = from h in allHouses >> where h.IsValid >> select h; >> >> Console.WriteLine("{0} valid houses", validHouses.Count()); >> >> var streets = from h1 in validHouses >> where h1.Order == 0 >> join h2 in validHouses on 1 equals h2.Order >> join h3 in validHouses on 2 equals h3.Order >> join h4 in validHouses on 3 equals h4.Order >> join h5 in validHouses on 4 equals h5.Order >> select new Street(h1, h2, h3, h4, h5); >> >> Console.WriteLine("{0} total street permutations.", >> streets.Count()); >> >> var result = from s in streets >> where s.IsValid >> select s; >> >> foreach (Street h in result) >> { >> Console.WriteLine(h.DescribeStreet()); >> } >> >> Console.ReadKey(); >> } >> } >> >> >> >> } >> >>> Jordan- Hide quoted text - >> - Show quoted text - > > 3 seconds... that is even faster than the SQL example. Linq seems to > have provided the fastest solution yet! > > Does changing the order of the enum lists have any noticeable affect > on the time? > I'll have to try that tonight. Just to clarify, are you talking about changing the order of the values within the enums, or changing the order in which the enums are joined together to form the list of House permutations? I'm assuming the former. I wouldn't think that it would have any effect, though, because unlike your code mine iterates over all of the possible Street permutations no matter what. If I remember correctly yours had a short-circuit where if it found a valid street it stopped processing, right? Were your performance differences because of that short circuit, where a correct answer early in the list of Street permutations short-circuits the rest of the list? > Jordan > |
|
#62
| |||
| |||
| Jordan Marr wrote: > On Jun 17, 8:48 pm, Kreeg <k...{}sentdotcom.nospam> wrote: >> Jordan Marr wrote: >>> I never posted my solution to Whose Fish, and since my old thread >>> probably has a stigma attached to it, I'll post it here. >> *SNIP the rest of Jordan's code* >> >> I had commented earlier that I'd like to see a linq implementation of >> this problem. Well, in an attempt to salvage this thread at least a >> little bit, I thought I'd give one a try. >> >> I used Jordan's OO implementation as a base, and basically used his >> entity objects without modification (I did end up adding a constructor >> to the Street class). >> >> Jordan's code that I stole so much from can be found here: >> >> http://groups.google.com/group/comp....c3044ff3069baa >> >> I cheated a bit (well, maybe a lot) and just used his IsValid rules to >> do my filtering, and used linq to make some other parts of the code a >> little clearer and more compact, I think. I actually end up liking the >> finished product a fair bit. Maybe I'll try to make it all linq in the >> future, but here's what I have. It's the first Linq that I've done, so >> I may well have missed some obvious things. >> >> On my laptop (a lowly centrino 1.4ghz) this runs in about 3 seconds. >> >> using System; >> using System.Collections.Generic; >> using System.Linq; >> using System.Text; >> using BusinessFramework; >> using Entities; >> >> namespace Whose_Fish >> { >> class LinqProgram >> { >> public void Solve() >> { >> //no cross join in linq AFAIK, so I have to do an inner >> join on 1 == 1 >> var allHouses = from Nationalities n in >> Enum.GetValues(typeof(Nationalities)) >> join HouseColors c in >> Enum.GetValues(typeof(HouseColors)) on 1 equals 1 >> join Drinks d in >> Enum.GetValues(typeof(Drinks)) on 1 equals 1 >> join Pets p in >> Enum.GetValues(typeof(Pets)) on 1 equals 1 >> join Smokes s in >> Enum.GetValues(typeof(Smokes)) on 1 equals 1 >> join int o in new int[]{0,1,2,3,4} on 1 >> equals 1 >> select new House() { Nationality = n, >> HouseColor = c, Drink = d, Order=o, Pet=p, Smoke=s }; >> >> var validHouses = from h in allHouses >> where h.IsValid >> select h; >> >> Console.WriteLine("{0} valid houses", validHouses.Count()); >> >> var streets = from h1 in validHouses >> where h1.Order == 0 >> join h2 in validHouses on 1 equals h2.Order >> join h3 in validHouses on 2 equals h3.Order >> join h4 in validHouses on 3 equals h4.Order >> join h5 in validHouses on 4 equals h5.Order >> select new Street(h1, h2, h3, h4, h5); >> >> Console.WriteLine("{0} total street permutations.", >> streets.Count()); >> >> var result = from s in streets >> where s.IsValid >> select s; >> >> foreach (Street h in result) >> { >> Console.WriteLine(h.DescribeStreet()); >> } >> >> Console.ReadKey(); >> } >> } >> >> >> >> } >> >>> Jordan- Hide quoted text - >> - Show quoted text - > > 3 seconds... that is even faster than the SQL example. Linq seems to > have provided the fastest solution yet! > > Does changing the order of the enum lists have any noticeable affect > on the time? > My apologies if this ends up double-posting. :-/ I'll have to try that tonight. Just to clarify, are you talking about changing the order of the values within the enums, or changing the order in which the enums are joined together to form the list of House permutations? I'm assuming the former. I wouldn't think that it would have any effect, though, because unlike your code mine iterates over all of the possible Street permutations no matter what. If I remember correctly yours had a short-circuit where if it found a valid street it stopped processing, right? Were your performance differences because of that short circuit, where a correct answer early in the list of Street permutations short-circuits the rest of the list? > Jordan > |
|
#63
| |||
| |||
| Jordan Marr wrote: > On Jun 17, 8:48 pm, Kreeg <k...{}sentdotcom.nospam> wrote: >> Jordan Marr wrote: >>> I never posted my solution to Whose Fish, and since my old thread >>> probably has a stigma attached to it, I'll post it here. >> *SNIP the rest of Jordan's code* >> >> I had commented earlier that I'd like to see a linq implementation of >> this problem. Well, in an attempt to salvage this thread at least a >> little bit, I thought I'd give one a try. >> >> I used Jordan's OO implementation as a base, and basically used his >> entity objects without modification (I did end up adding a constructor >> to the Street class). >> >> Jordan's code that I stole so much from can be found here: >> >> http://groups.google.com/group/comp....c3044ff3069baa >> >> I cheated a bit (well, maybe a lot) and just used his IsValid rules to >> do my filtering, and used linq to make some other parts of the code a >> little clearer and more compact, I think. I actually end up liking the >> finished product a fair bit. Maybe I'll try to make it all linq in the >> future, but here's what I have. It's the first Linq that I've done, so >> I may well have missed some obvious things. >> >> On my laptop (a lowly centrino 1.4ghz) this runs in about 3 seconds. >> >> using System; >> using System.Collections.Generic; >> using System.Linq; >> using System.Text; >> using BusinessFramework; >> using Entities; >> >> namespace Whose_Fish >> { >> class LinqProgram >> { >> public void Solve() >> { >> //no cross join in linq AFAIK, so I have to do an inner >> join on 1 == 1 >> var allHouses = from Nationalities n in >> Enum.GetValues(typeof(Nationalities)) >> join HouseColors c in >> Enum.GetValues(typeof(HouseColors)) on 1 equals 1 >> join Drinks d in >> Enum.GetValues(typeof(Drinks)) on 1 equals 1 >> join Pets p in >> Enum.GetValues(typeof(Pets)) on 1 equals 1 >> join Smokes s in >> Enum.GetValues(typeof(Smokes)) on 1 equals 1 >> join int o in new int[]{0,1,2,3,4} on 1 >> equals 1 >> select new House() { Nationality = n, >> HouseColor = c, Drink = d, Order=o, Pet=p, Smoke=s }; >> >> var validHouses = from h in allHouses >> where h.IsValid >> select h; >> >> Console.WriteLine("{0} valid houses", validHouses.Count()); >> >> var streets = from h1 in validHouses >> where h1.Order == 0 >> join h2 in validHouses on 1 equals h2.Order >> join h3 in validHouses on 2 equals h3.Order >> join h4 in validHouses on 3 equals h4.Order >> join h5 in validHouses on 4 equals h5.Order >> select new Street(h1, h2, h3, h4, h5); >> >> Console.WriteLine("{0} total street permutations.", >> streets.Count()); >> >> var result = from s in streets >> where s.IsValid >> select s; >> >> foreach (Street h in result) >> { >> Console.WriteLine(h.DescribeStreet()); >> } >> >> Console.ReadKey(); >> } >> } >> >> >> >> } >> >>> Jordan- Hide quoted text - >> - Show quoted text - > > 3 seconds... that is even faster than the SQL example. Linq seems to > have provided the fastest solution yet! > > Does changing the order of the enum lists have any noticeable affect > on the time? > My apologies if this ends up double-posting. :-/ I'll have to try that. Just to clarify, are you talking about changing the order of the values within the enums, or changing the order in which the enums are joined together to form the list of House permutations? I'm assuming the former. I wouldn't think that it would have any effect, though, because unlike your code mine iterates over all of the possible Street permutations no matter what. If I remember correctly yours had a short-circuit where if it found a valid street it stopped processing, right? Were your performance differences because of that short circuit, where a correct answer early in the list of Street permutations short-circuits the rest of the list? > Jordan > |
|
#64
| |||
| |||
| On Jun 18, 3:04 pm, Kreeg <k...{}sentdotcom.nospam.com> wrote: > Jordan Marr wrote: > > On Jun 17, 8:48 pm, Kreeg <k...{}sentdotcom.nospam> wrote: > >> Jordan Marr wrote: > >>> I never posted my solution to Whose Fish, and since my old thread > >>> probably has a stigma attached to it, I'll post it here. > >> *SNIP the rest of Jordan's code* > > >> I had commented earlier that I'd like to see a linq implementation of > >> this problem. Well, in an attempt to salvage this thread at least a > >> little bit, I thought I'd give one a try. > > >> I used Jordan's OO implementation as a base, and basically used his > >> entity objects without modification (I did end up adding a constructor > >> to the Street class). > > >> Jordan's code that I stole so much from can be found here: > > >>http://groups.google.com/group/comp....c3044ff3069baa > > >> I cheated a bit (well, maybe a lot) and just used his IsValid rules to > >> do my filtering, and used linq to make some other parts of the code a > >> little clearer and more compact, I think. I actually end up liking the > >> finished product a fair bit. Maybe I'll try to make it all linq in the > >> future, but here's what I have. It's the first Linq that I've done, so > >> I may well have missed some obvious things. > > >> On my laptop (a lowly centrino 1.4ghz) this runs in about 3 seconds. > > >> using System; > >> using System.Collections.Generic; > >> using System.Linq; > >> using System.Text; > >> using BusinessFramework; > >> using Entities; > > >> namespace Whose_Fish > >> { > >> class LinqProgram > >> { > >> public void Solve() > >> { > >> //no cross join in linq AFAIK, so I have to do an inner > >> join on 1 == 1 > >> var allHouses = from Nationalities n in > >> Enum.GetValues(typeof(Nationalities)) > >> join HouseColors c in > >> Enum.GetValues(typeof(HouseColors)) on 1 equals 1 > >> join Drinks d in > >> Enum.GetValues(typeof(Drinks)) on 1 equals 1 > >> join Pets p in > >> Enum.GetValues(typeof(Pets)) on 1 equals 1 > >> join Smokes s in > >> Enum.GetValues(typeof(Smokes)) on 1 equals 1 > >> join int o in new int[]{0,1,2,3,4} on 1 > >> equals 1 > >> select new House() { Nationality = n, > >> HouseColor = c, Drink = d, Order=o, Pet=p, Smoke=s }; > > >> var validHouses = from h in allHouses > >> where h.IsValid > >> select h; > > >> Console.WriteLine("{0} valid houses", validHouses.Count()); > > >> var streets = from h1 in validHouses > >> where h1.Order == 0 > >> join h2 in validHouses on 1 equals h2.Order > >> join h3 in validHouses on 2 equals h3.Order > >> join h4 in validHouses on 3 equals h4.Order > >> join h5 in validHouses on 4 equals h5.Order > >> select new Street(h1, h2, h3, h4, h5); > > >> Console.WriteLine("{0} total street permutations.", > >> streets.Count()); > > >> var result = from s in streets > >> where s.IsValid > >> select s; > > >> foreach (Street h in result) > >> { > >> Console.WriteLine(h.DescribeStreet()); > >> } > > >> Console.ReadKey(); > >> } > >> } > > >> } > > >>> Jordan- Hide quoted text - > >> - Show quoted text - > > > 3 seconds... that is even faster than the SQL example. Linq seems to > > have provided the fastest solution yet! > > > Does changing the order of the enum lists have any noticeable affect > > on the time? > > I'll have to try that tonight. Just to clarify, are you talking about > changing the order of the values within the enums, or changing the order > in which the enums are joined together to form the list of House > permutations? I'm assuming the former. > > I wouldn't think that it would have any effect, though, because unlike > your code mine iterates over all of the possible Street permutations no > matter what. If I remember correctly yours had a short-circuit where if > it found a valid street it stopped processing, right? Were your > performance differences because of that short circuit, where a correct > answer early in the list of Street permutations short-circuits the rest > of the list? > > > > > Jordan- Hide quoted text - > > - Show quoted text -- Hide quoted text - > > - Show quoted text - That is correct. It iterates until it finds a valid street and then stops. So you're saying that the Linq solution iterates all streets (no short circuit). If the same validation logic is taking place *more times* in the Linq version, how does Linq make it run so much faster? It still has to loop through and run the validation algorithm. Thoughts? Jordan |
|
#65
| |||
| |||
| Jordan Marr wrote: > On Jun 18, 3:04 pm, Kreeg <k...{}sentdotcom.nospam.com> wrote: >> Jordan Marr wrote: >>> On Jun 17, 8:48 pm, Kreeg <k...{}sentdotcom.nospam> wrote: >>>> Jordan Marr wrote: >>>>> I never posted my solution to Whose Fish, and since my old thread >>>>> probably has a stigma attached to it, I'll post it here. >>>> *SNIP the rest of Jordan's code* >>>> I had commented earlier that I'd like to see a linq implementation of >>>> this problem. Well, in an attempt to salvage this thread at least a >>>> little bit, I thought I'd give one a try. >>>> I used Jordan's OO implementation as a base, and basically used his >>>> entity objects without modification (I did end up adding a constructor >>>> to the Street class). >>>> Jordan's code that I stole so much from can be found here: >>>> http://groups.google.com/group/comp....c3044ff3069baa >>>> I cheated a bit (well, maybe a lot) and just used his IsValid rules to >>>> do my filtering, and used linq to make some other parts of the code a >>>> little clearer and more compact, I think. I actually end up liking the >>>> finished product a fair bit. Maybe I'll try to make it all linq in the >>>> future, but here's what I have. It's the first Linq that I've done, so >>>> I may well have missed some obvious things. >>>> On my laptop (a lowly centrino 1.4ghz) this runs in about 3 seconds. >>>> using System; >>>> using System.Collections.Generic; >>>> using System.Linq; >>>> using System.Text; >>>> using BusinessFramework; >>>> using Entities; >>>> namespace Whose_Fish >>>> { >>>> class LinqProgram >>>> { >>>> public void Solve() >>>> { >>>> //no cross join in linq AFAIK, so I have to do an inner >>>> join on 1 == 1 >>>> var allHouses = from Nationalities n in >>>> Enum.GetValues(typeof(Nationalities)) >>>> join HouseColors c in >>>> Enum.GetValues(typeof(HouseColors)) on 1 equals 1 >>>> join Drinks d in >>>> Enum.GetValues(typeof(Drinks)) on 1 equals 1 >>>> join Pets p in >>>> Enum.GetValues(typeof(Pets)) on 1 equals 1 >>>> join Smokes s in >>>> Enum.GetValues(typeof(Smokes)) on 1 equals 1 >>>> join int o in new int[]{0,1,2,3,4} on 1 >>>> equals 1 >>>> select new House() { Nationality = n, >>>> HouseColor = c, Drink = d, Order=o, Pet=p, Smoke=s }; >>>> var validHouses = from h in allHouses >>>> where h.IsValid >>>> select h; >>>> Console.WriteLine("{0} valid houses", validHouses.Count()); >>>> var streets = from h1 in validHouses >>>> where h1.Order == 0 >>>> join h2 in validHouses on 1 equals h2.Order >>>> join h3 in validHouses on 2 equals h3.Order >>>> join h4 in validHouses on 3 equals h4.Order >>>> join h5 in validHouses on 4 equals h5.Order >>>> select new Street(h1, h2, h3, h4, h5); >>>> Console.WriteLine("{0} total street permutations.", >>>> streets.Count()); >>>> var result = from s in streets >>>> where s.IsValid >>>> select s; >>>> foreach (Street h in result) >>>> { >>>> Console.WriteLine(h.DescribeStreet()); >>>> } >>>> Console.ReadKey(); >>>> } >>>> } >>>> } >>>>> Jordan- Hide quoted text - >>>> - Show quoted text - >>> 3 seconds... that is even faster than the SQL example. Linq seems to >>> have provided the fastest solution yet! >>> Does changing the order of the enum lists have any noticeable affect >>> on the time? >> I'll have to try that tonight. Just to clarify, are you talking about >> changing the order of the values within the enums, or changing the order >> in which the enums are joined together to form the list of House >> permutations? I'm assuming the former. >> >> I wouldn't think that it would have any effect, though, because unlike >> your code mine iterates over all of the possible Street permutations no >> matter what. If I remember correctly yours had a short-circuit where if >> it found a valid street it stopped processing, right? Were your >> performance differences because of that short circuit, where a correct >> answer early in the list of Street permutations short-circuits the rest >> of the list? >> >> >> >>> Jordan- Hide quoted text - >> - Show quoted text -- Hide quoted text - >> >> - Show quoted text - > > That is correct. It iterates until it finds a valid street and then > stops. > So you're saying that the Linq solution iterates all streets (no short > circuit). If the same validation logic is taking place *more times* > in the Linq version, how does Linq make it run so much faster? It > still has to loop through and run the validation algorithm. > > Thoughts? > When you timed your solution, did you have the Console.Writeline in each iteration? I had your implementation up and running on my machine without outputting to the console, and it ran in about the same amount of time as the Linq solution. > Jordan > |
|
#66
| |||
| |||
| On Jun 20, 4:24 pm, Kreeg <k...{}sentdotcom.nospam> wrote: > Jordan Marr wrote: > > On Jun 18, 3:04 pm, Kreeg <k...{}sentdotcom.nospam.com> wrote: > >> Jordan Marr wrote: > >>> On Jun 17, 8:48 pm, Kreeg <k...{}sentdotcom.nospam> wrote: > >>>> Jordan Marr wrote: > >>>>> I never posted my solution to Whose Fish, and since my old thread > >>>>> probably has a stigma attached to it, I'll post it here. > >>>> *SNIP the rest of Jordan's code* > >>>> I had commented earlier that I'd like to see a linq implementation of > >>>> this problem. Well, in an attempt to salvage this thread at least a > >>>> little bit, I thought I'd give one a try. > >>>> I used Jordan's OO implementation as a base, and basically used his > >>>> entity objects without modification (I did end up adding a constructor > >>>> to the Street class). > >>>> Jordan's code that I stole so much from can be found here: > >>>>http://groups.google.com/group/comp....c3044ff3069baa > >>>> I cheated a bit (well, maybe a lot) and just used his IsValid rules to > >>>> do my filtering, and used linq to make some other parts of the code a > >>>> little clearer and more compact, I think. I actually end up liking the > >>>> finished product a fair bit. Maybe I'll try to make it all linq in the > >>>> future, but here's what I have. It's the first Linq that I've done, so > >>>> I may well have missed some obvious things. > >>>> On my laptop (a lowly centrino 1.4ghz) this runs in about 3 seconds. > >>>> using System; > >>>> using System.Collections.Generic; > >>>> using System.Linq; > >>>> using System.Text; > >>>> using BusinessFramework; > >>>> using Entities; > >>>> namespace Whose_Fish > >>>> { > >>>> class LinqProgram > >>>> { > >>>> public void Solve() > >>>> { > >>>> //no cross join in linq AFAIK, so I have to do an inner > >>>> join on 1 == 1 > >>>> var allHouses = from Nationalities n in > >>>> Enum.GetValues(typeof(Nationalities)) > >>>> join HouseColors c in > >>>> Enum.GetValues(typeof(HouseColors)) on 1 equals 1 > >>>> join Drinks d in > >>>> Enum.GetValues(typeof(Drinks)) on 1 equals 1 > >>>> join Pets p in > >>>> Enum.GetValues(typeof(Pets)) on 1 equals 1 > >>>> join Smokes s in > >>>> Enum.GetValues(typeof(Smokes)) on 1 equals 1 > >>>> join int o in new int[]{0,1,2,3,4} on 1 > >>>> equals 1 > >>>> select new House() { Nationality = n, > >>>> HouseColor = c, Drink = d, Order=o, Pet=p, Smoke=s }; > >>>> var validHouses = from h in allHouses > >>>> where h.IsValid > >>>> select h; > >>>> Console.WriteLine("{0} valid houses", validHouses.Count()); > >>>> var streets = from h1 in validHouses > >>>> where h1.Order == 0 > >>>> join h2 in validHouses on 1 equals h2.Order > >>>> join h3 in validHouses on 2 equals h3.Order > >>>> join h4 in validHouses on 3 equals h4.Order > >>>> join h5 in validHouses on 4 equals h5.Order > >>>> select new Street(h1, h2, h3, h4, h5); > >>>> Console.WriteLine("{0} total street permutations.", > >>>> streets.Count()); > >>>> var result = from s in streets > >>>> where s.IsValid > >>>> select s; > >>>> foreach (Street h in result) > >>>> { > >>>> Console.WriteLine(h.DescribeStreet()); > >>>> } > >>>> Console.ReadKey(); > >>>> } > >>>> } > >>>> } > >>>>> Jordan- Hide quoted text - > >>>> - Show quoted text - > >>> 3 seconds... that is even faster than the SQL example. Linq seems to > >>> have provided the fastest solution yet! > >>> Does changing the order of the enum lists have any noticeable affect > >>> on the time? > >> I'll have to try that tonight. Just to clarify, are you talking about > >> changing the order of the values within the enums, or changing the order > >> in which the enums are joined together to form the list of House > >> permutations? I'm assuming the former. > > >> I wouldn't think that it would have any effect, though, because unlike > >> your code mine iterates over all of the possible Street permutations no > >> matter what. If I remember correctly yours had a short-circuit where if > >> it found a valid street it stopped processing, right? Were your > >> performance differences because of that short circuit, where a correct > >> answer early in the list of Street permutations short-circuits the rest > >> of the list? > > >>> Jordan- Hide quoted text - > >> - Show quoted text -- Hide quoted text - > > >> - Show quoted text - > > > That is correct. It iterates until it finds a valid street and then > > stops. > > So you're saying that the Linq solution iterates all streets (no short > > circuit). If the same validation logic is taking place *more times* > > in the Linq version, how does Linq make it run so much faster? It > > still has to loop through and run the validation algorithm. > > > Thoughts? > > When you timed your solution, did you have the Console.Writeline in each > iteration? I had your implementation up and running on my machine > without outputting to the console, and it ran in about the same amount > of time as the Linq solution. > > > > > Jordan- Hide quoted text - > > - Show quoted text -- Hide quoted text - > > - Show quoted text - Good catch my friend! It is so obvious that I completely overlooked how much time it adds to display each count on screen! I guess it just goes to show how much the industry has shifted my emphasis toward the notion that "visual interface == user satisfaction". Now my solution runs anywhere between 0 to 1 second. That is pretty much instantaneous! Jordan |
![]() |
| Thread Tools | |
| Display Modes | |
In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.