tag:blogger.com,1999:blog-7577421612120825312.post2469091762645490493..comments2023-10-03T10:41:13.944+01:00Comments on Functional Fun: Project Euler Problem 9Anonymoushttp://www.blogger.com/profile/01345100698738870730noreply@blogger.comBlogger6125tag:blogger.com,1999:blog-7577421612120825312.post-55765469650254265172011-05-19T13:09:47.707+01:002011-05-19T13:09:47.707+01:00Similar solution:
var range = Enumerable.Range(1,...Similar solution:<br /><br />var range = Enumerable.Range(1, 500);var triplets = range.SelectMany(a => range.Where(b => a < b).Select(b => new {A = a, B = b, C = (1000 - a - b)}));var triplet = triplets.FirstOrDefault(t => t.A*t.A + t.B*t.B == t.C*t.C);return triplet.A*triplet.B*triplet.C;Chrisnoreply@blogger.comtag:blogger.com,1999:blog-7577421612120825312.post-83231589907446262582011-05-16T15:49:51.195+01:002011-05-16T15:49:51.195+01:00Sam:I found a solution to this problem using eleme...Sam:<br><br>I found a solution to this problem using elementary number theory to keep my old Math engine just cranking ;-). From the mathematical point of view, it's interesting too.<br><br>Keep up the blog, I've been fascinated the good use you have been giving to Generics. <br><br>I also believe little comments mean little time to. It's not easy to live in this 24h world with 8h sleeps and also comment in your blog. I will do my biggest effort circa 2 a.m.<br><br>Cheers, <br>Romanroman_fresnedahttp://www.blogger.com/profile/15765341519444055469noreply@blogger.comtag:blogger.com,1999:blog-7577421612120825312.post-33549951575496571282011-05-16T15:49:50.847+01:002011-05-16T15:49:50.847+01:00Hey, thanks for teaching me about Anonymous types!...Hey, thanks for teaching me about Anonymous types! I've got a lot of programming background in various languages, so your examples are pretty much the ideal tutorial for me; I don't need a lot of excess explanation. <br><br>One thought: You can trim your conditions down a bit. Since a< b < c, a can never be above 331, and b can never be above 499. Not a huge change, but anyway.<br><br>Thanks again,<br><br>-t.Tristanhttp://www.blogger.com/profile/11770063054853613781noreply@blogger.comtag:blogger.com,1999:blog-7577421612120825312.post-33781621754993627672009-12-02T12:01:32.235+00:002009-12-02T12:01:32.235+00:00since squares end with 0,1,4,5,6,9 (a,b) pairs ca...since squares end with 0,1,4,5,6,9 (a,b) pairs cannot be (**1,**4) ,(**1,**6),(**4,**6) and so on , since in those cases their sum wont be a square(ending with 2,3,7,8), and thus some cases can be omitted......Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-7577421612120825312.post-19369366213409576342008-12-31T00:40:00.000+00:002008-12-31T00:40:00.000+00:00Hey, thanks for teaching me about Anonymous types!...Hey, thanks for teaching me about Anonymous types! I've got a lot of programming background in various languages, so your examples are pretty much the ideal tutorial for me; I don't need a lot of excess explanation. <BR/><BR/>One thought: You can trim your conditions down a bit. Since a< b < c, a can never be above 331, and b can never be above 499. Not a huge change, but anyway.<BR/><BR/>Thanks again,<BR/><BR/>-t.Tristan Reidhttps://www.blogger.com/profile/11770063054853613781noreply@blogger.comtag:blogger.com,1999:blog-7577421612120825312.post-40520701801399419012008-05-06T00:52:00.000+01:002008-05-06T00:52:00.000+01:00Sam:I found a solution to this problem using eleme...Sam:<BR/><BR/>I found a solution to this problem using elementary number theory to keep my old Math engine just cranking ;-). From the mathematical point of view, it's interesting too.<BR/><BR/>Keep up the blog, I've been fascinated the good use you have been giving to Generics. <BR/><BR/>I also believe little comments mean little time to. It's not easy to live in this 24h world with 8h sleeps and also comment in your blog. I will do my biggest effort circa 2 a.m.<BR/><BR/>Cheers, <BR/>RomanRomán Fresneda Quirogahttps://www.blogger.com/profile/15765341519444055469noreply@blogger.com