Created
January 4, 2017 12:40
-
-
Save MikeMKH/b5773170af92fab0d32fed8524137e77 to your computer and use it in GitHub Desktop.
FizzBuzz kata in C# using .Net Core with macOS
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
| MacBook-Pro:~/Kata/netcore/hello$ dotnet run | |
| Project hello (.NETCoreApp,Version=v1.1) will be compiled because inputs were modified | |
| Compiling hello for .NETCoreApp,Version=v1.1 | |
| Compilation succeeded. | |
| 0 Warning(s) | |
| 0 Error(s) | |
| Time elapsed 00:00:00.9231498 | |
| 2 is 2 | |
| 3 is Fizz | |
| 4 is 4 | |
| 5 is Buzz | |
| 6 is Fizz | |
| 10 is Buzz | |
| 15 is FizzBuzz | |
| 45 is FizzBuzz |
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
| { | |
| "version": "1.0.0-*", | |
| "buildOptions": { | |
| "debugType": "portable", | |
| "emitEntryPoint": true | |
| }, | |
| "dependencies": {}, | |
| "frameworks": { | |
| "netcoreapp1.1": { | |
| "dependencies": { | |
| "Microsoft.NETCore.App": { | |
| "type": "platform", | |
| "version": "1.1.0" | |
| } | |
| }, | |
| "imports": "dnxcore50" | |
| } | |
| } | |
| } |
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; | |
| using System.Collections.Generic; | |
| namespace ConsoleApplication | |
| { | |
| public class Program | |
| { | |
| public static void Main(string[] args) | |
| { | |
| var values = new List<int> { 2, 3, 4, 5, 6, 10, 15, 45 }; | |
| values.ForEach(value => Console.WriteLine($"{value} is {value.FizzBuzz()}")); | |
| } | |
| } | |
| public static class Wrapper | |
| { | |
| public static string FizzBuzz(this int value) | |
| { | |
| var fizzy = value % 3 == 0; | |
| var buzzy = value % 5 == 0; | |
| if ( fizzy && buzzy) return "FizzBuzz"; | |
| if ( fizzy && !buzzy) return "Fizz"; | |
| if (!fizzy && buzzy) return "Buzz"; | |
| if (!fizzy && !buzzy) return value.ToString(); | |
| return "No idea how we got here"; | |
| } | |
| } | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello .Net Core on my Mac.