diff --git a/README.md b/README.md index f7fdde3..ab75211 100644 --- a/README.md +++ b/README.md @@ -82,3 +82,8 @@ if __name__ == "__main__": This repo contains a [sample file](https://github.com/kevsmith/code_golf/blob/main/input.txt) you can use for development. +#### HOW TO RUN +dotnet new console --use-program-main false +Copy contents from TheFileLengthOfThisFileDoesntMatterAtAll.cs to Program.cs +Delete TheFileLengthOfThisFileDoesntMatterAtAll.cs file +dotnet run input.txt diff --git a/TheFileLengthOfThisFileDoesntMatterAtAll.cs b/TheFileLengthOfThisFileDoesntMatterAtAll.cs new file mode 100644 index 0000000..c63db56 --- /dev/null +++ b/TheFileLengthOfThisFileDoesntMatterAtAll.cs @@ -0,0 +1,19 @@ +using System; +using System.IO; +class Program{ + static void Main(string[] args){ + var values = new[]{1000,900,500,400,100,90,50,40,10,9,5,4,1}; + var symbols = new[]{"M","CM","D","CD","C","XC","L","XL","X","IX","V","IV","I"}; + foreach(var line in File.ReadLines(args[0])){ + int number = int.Parse(line); + var roman = ""; + for(int i = 0; i < values.Length; i++){ + while(number >= values[i]){ + roman += symbols[i]; + number -= values[i]; + } + } + Console.WriteLine(roman); + } + } +}