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
  • 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
  • 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
  • Euler Problem 4: Finding Palindrome numbers

    The fourth Euler problem asks you to find the largest palindrome number that is the product of two three digit numbers. For example, the number 919 is a palindrome: it's the same forward and backwards. To solve this problem, we need to find the product of all combinations of three digit numbers....
    Posted to Bill Blogs in C# (Weblog) by wwagner on Sun, Apr 6 2008
  • Notes on Euler Problem 3

    Here are my notes on the third Project Euler problem. The problem is "What is the largest prime factor of the number 600,851,475,143?" Once again, this is a problem that is best solved creating some simple LINQ queries. From the outside, this query generates the list of all prime factors in...
    Posted to Bill Blogs in C# (Weblog) by wwagner on Fri, Mar 28 2008
  • Discussion on Project Euler Problem 2

    The second Euler problem asks you to find the sum of all even valued terms in the Fibonacci sequence which do not exceed 4,000,000. Let's look at the solution from the outside in. Here's the query that finds the answer: var EvenFibNumbers = (from n in Enumerable.Range(1, MAX) let value = FibonacciSequence...
    Posted to Bill Blogs in C# (Weblog) by wwagner on Thu, Mar 27 2008

In our last colurm, we wrote about how technical mentors can benefit companies ( Ann Arbor Business Review, May 22, 2008 ). In this installment, we're...