diff --git a/Luke Skrzypek Submission/1 - Python/RomanNumeralsPython.py b/Luke Skrzypek Submission/1 - Python/RomanNumeralsPython.py new file mode 100644 index 0000000..6c6ca5f --- /dev/null +++ b/Luke Skrzypek Submission/1 - Python/RomanNumeralsPython.py @@ -0,0 +1,6 @@ +import sys +def F(n,c): + return((((c[::2],c[1]+c[0]*(n-5))[n<9]),c[:2])[n==4],c[0]*n)[n<4] +for s in open(sys.argv[1]): + n=int(s) + print(n//1000*'M'+F(n//100%10,'CDM')+F(n//10%10,'XLC')+F(n%10,'IVX')) diff --git a/Luke Skrzypek Submission/2 - Javascript/RomanNumerals.js b/Luke Skrzypek Submission/2 - Javascript/RomanNumerals.js new file mode 100644 index 0000000..616cd28 --- /dev/null +++ b/Luke Skrzypek Submission/2 - Javascript/RomanNumerals.js @@ -0,0 +1,4 @@ +o=require('fs') +F=(n,f,i,d)=>n<4?f.repeat(n):n==4?f+i:n<9?i+f.repeat(n-5):f+d +o.readFileSync(process.argv[2],'utf8').split('\n').forEach(x=>n=-(-x) +console.log('M'.repeat(n/1e3|0)+F(n/100%10|0,'C','D','M')+F(n/10%10|0,'X','L','C')+F(n%10|0,'I','V','X'))) \ No newline at end of file diff --git a/Luke Skrzypek Submission/3 - C#/Program.cs b/Luke Skrzypek Submission/3 - C#/Program.cs new file mode 100644 index 0000000..5422b6b --- /dev/null +++ b/Luke Skrzypek Submission/3 - C#/Program.cs @@ -0,0 +1 @@ +using S=string;var F=(int n,char f,char i,S d)=>n<4?new S(f,n):n==4?$"{f}{i}":n<9?i+new S(f,n-5):d;File.ReadAllText(args[0]).Split('\n').ToList().ForEach(l=>{var n=int.Parse(l);Console.WriteLine($"{new S('M',n/1000)}{F(n/100%10,'C','D',"CM")}{F(n/10%10,'X','L',"XC")}{F(n%10,'I','V',"IX")}");}); \ No newline at end of file diff --git a/Luke Skrzypek Submission/3 - C#/RomanNumerals.csproj b/Luke Skrzypek Submission/3 - C#/RomanNumerals.csproj new file mode 100644 index 0000000..fd4bd08 --- /dev/null +++ b/Luke Skrzypek Submission/3 - C#/RomanNumerals.csproj @@ -0,0 +1,10 @@ + + + + Exe + net9.0 + enable + enable + + + diff --git a/Luke Skrzypek Submission/README.md b/Luke Skrzypek Submission/README.md new file mode 100644 index 0000000..a7b36f6 --- /dev/null +++ b/Luke Skrzypek Submission/README.md @@ -0,0 +1,6 @@ +This includes all three of my attempts with the main one (shortest) being the one in `1- Python`. +The others have been included for posterity :) + +1) Python: `python RomanNumeralsPython.py ` - 185 chars without spaces +2) Javascript: `node RomanNumerals.js ` - 251 chars without spaces +3) C#: `dotnet build RomanNumerals.csproj` - 288 chars without spaces \ No newline at end of file