The Next Home of Chris Chapman's Free Thoughts on Agile, .NET, SharePoint, what-have-you, whatnot. 
Page 1 of 1 in the fizzbuzz category
# Friday, April 06, 2007
I know, I know.  I'm just one more in the litany of pundits offering their opinion on the FizzBuzz test that Jeff Atwood described in his Feb/07 blog post, among many others.  It intrigued me to see what the big deal was and how panicked I might get if I was issued the challenge in an interview.
 
For the uninitiated, the FizzBuzz test requires a programmer candidate to write a simple program that outputs the number 1 to 100 with a twist:  Numbers that are a multiple of three are replaced with the word "fizz";  those that are a multiple of five are replaced with "buzz".  Those that are a multiple of three and five are replaced with "fizzbuzz".
 
It's a simple enough problem that makes your fingers itch to write the loop and get to it.  I must admit that the solution I came up with was not my first - I arrived at the code below after thinking of a refactoring.  All in all, it took me under 10 minutes, which I think would be ok under Atwood's guidelines:

public
void RunFizzBuzz()
{
    
for (int n = 1; n <= 100; n++)
    {
        
Console.Write((n % 3 == 0 && n % 5 == 0) ? "fizzbuzz" :
            (n % 3 == 0) ?
"fizz" : (n % 5 == 0) ? "buzz" : n.ToString());
        
Console.Write("\n");
    }
}
 

Originally, I approached the solution from the wrong way 'round, starting with checking for a multiple of 3, then 5.  Checking for the multiples of 3 and 5 first made for a much more streamlined solution.

Right then!  I am eminently qualified for any programming position...

Friday, April 06, 2007 5:40:29 PM (Eastern Daylight Time, UTC-04:00)  #    Comments [0] -
fizzbuzz | skills | software development

About Me
I am a Toronto-based software consultant specializing in SharePoint, .NET technologies and agile/iterative/lean software project management practices. Currently, I am employed by Microsoft Consulting Services (MCS) Canada as an Application Development and Information Worker Consultant, focusing on delivering guidance and subject matter expertise to enterprise customers who have or are in the process of deploying Microsoft technologies.

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

© Copyright 2010
Chris R. Chapman
Sign In
Archive
<March 2010>
SunMonTueWedThuFriSat
28123456
78910111213
14151617181920
21222324252627
28293031123
45678910
Statistics
Total Posts: 194
This Year: 2
This Month: 0
This Week: 0
Comments: 109
All Content © 2010, Chris R. Chapman
DasBlog theme 'Business' created by Christoph De Baene (delarou)