SRT Solutions

Blogs

Browse by Tags

  • Euler Problem 10

    Patrick posted his solution earlier this week. I figure it was time to add mine. Also, Octavio Hernandez pointed out in the comments to problem 8 that he had discussed similar code constructs in his blog a while back. Problem 10 asks for the sum of all primes less than 2 million. It's also one line...
    Posted to Bill Blogs in C# (Weblog) by wwagner on Sun, Aug 31 2008
  • Code from Lightning Talk: Compiler Tricks

    My last Lightning Talk should how you can mix constructor calls and object initializers. It's a useful technique that can keep you from writing too much code you don't need. To see what I mean, start with this simple person class: 1: class Person 2: { 3: public string FirstName 4: { 5: get; 6...
    Posted to Bill Blogs in C# (Weblog) by wwagner on Sat, Aug 30 2008
  • Euler Problem 9

    I was going to wait a bit to post this, but Patrick Steele posted his solution , so I figured I should post mine. Patrick took the straight out brute force approach. I decided to think a bit differently and use the some LINQ code to generate my answer. The problem is to find the only Pythagorean triplet...
    Posted to Bill Blogs in C# (Weblog) by wwagner on Thu, Aug 28 2008
  • Euler Problem 7

    Yes, it's true that I've been very lax in working on these problems. It's been a combination of the day job, finishing all the editing tasks on "More Effective C#", and actually trying to keep the personal life intact. The 7th problem is quite straightforward: find the 10,001st...
    Posted to Bill Blogs in C# (Weblog) by wwagner on Thu, Aug 14 2008
  • Overload Resolution on Extension Methods

    I had a question from a colleague the other day about extension methods. I'm simplifying a little, but he was looking for a way to ensure that every source file used the same set of extension methods. There is one way to enforce this, but it does have an effect on your code organization. Section...
    Posted to Bill Blogs in C# (Weblog) by wwagner on Sun, Aug 10 2008
  • Q & A on a recent VSM Article

    One of my last Visual Studio Magazine article discussed object validation and object invariants. I received a great email discussing questions about how to handle UI validation in this world. My recommendation in the article was that classes should be responsible for their own state. Furthermore, they...
    Posted to Bill Blogs in C# (Weblog) by wwagner on Tue, Jul 22 2008
  • A Functional Programming Q & A

    I received this question in email from one of my readers, and I thought it would be of general interest: I find myself with two arrays of the same size and I want to create a third that combines each element. What I want is something similar to var S3 = S1.foreach(S2, (s1, s2) => s1 + s2); this would...
    Posted to Bill Blogs in C# (Weblog) by wwagner on Wed, Apr 23 2008
  • The Obligatory Post-MVP Summit Post

    Well, I'm back from the MVP Summit, and it seems that tradition mandates a summary of the trip. But there is one problem: The best content was all under NDA. Most MVPs spend their time with members of the product team for their award, and other teams that are related. For me, that obviously means...
    Posted to Bill Blogs in C# (Weblog) by wwagner on Tue, Apr 22 2008
  • Project Euler problem 6

    Euler Problem six asks you to find the difference between the sum of squares and the square of the sum for the natural numbers 1 through 100. I took the easy route, and made a brute force implementation in C#. There are a couple new bits of LINQ syntax here. This query creates two different anonymous...
    Posted to Bill Blogs in C# (Weblog) by wwagner on Fri, Apr 11 2008
  • Euler Problem 5

    Well, it's time to post another solution and look at how LINQ and C# 3.0 can create elegant code for these problems. The fifth problem asks you to find the smallest number that is divisible by all the natural numbers from 1 through 20. You can trivially find the answer like this: 1 private static...
    Posted to Bill Blogs in C# (Weblog) by wwagner on Tue, Apr 8 2008

As a business leader, you've undoubtedly nurtured your company's image in the marketplace. You take great care in ensuring that your customers...