Skip to content

Instantly share code, notes, and snippets.

@damonjmurray
Last active August 29, 2015 13:57
Show Gist options
  • Save damonjmurray/9733097 to your computer and use it in GitHub Desktop.
Save damonjmurray/9733097 to your computer and use it in GitHub Desktop.
A FizzBuzz solution that collapses a string array using string.Join to produce the desired output
using System;
using System.Linq;
namespace FizzBuzzCollapsedStringArray
{
public class Program
{
public static void Main(string[] args)
{
Enumerable.Range(1, 100).Select(i => string.Join(string.Empty, new[]
{
i%3 == 0 ? "Fizz" : string.Empty,
i%5 == 0 ? "Buzz" : string.Empty,
(i%3)*(i%5) != 0 ? i.ToString() : string.Empty
})).ToList().ForEach(Console.WriteLine);
Console.ReadLine();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment