Created
December 20, 2017 21:12
-
-
Save TheBuzzSaw/f178e2eda0060f47572e165c5da5190c to your computer and use it in GitHub Desktop.
FizzBuzz just because
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| namespace FizzBuzz | |
| { | |
| class Program | |
| { | |
| static void PlayTheGame(int maxValue, params (int factor, string phrase)[] rules) | |
| { | |
| for (int i = 1; i <= maxValue; ++i) | |
| { | |
| bool showValue = true; | |
| foreach (var rule in rules) | |
| { | |
| if (i % rule.factor == 0) | |
| { | |
| Console.Write(rule.phrase); | |
| showValue = false; | |
| } | |
| } | |
| if (showValue) | |
| Console.WriteLine(i); | |
| else | |
| Console.WriteLine(); | |
| } | |
| } | |
| static void Main(string[] args) | |
| { | |
| PlayTheGame(100, (3, "Fizz"), (5, "Buzz")); | |
| PlayTheGame(100, (3, "Fizz"), (5, "Buzz"), (7, "Baz")); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment