Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Luke Skrzypek Submission/1 - Python/RomanNumeralsPython.py
Original file line number Diff line number Diff line change
@@ -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'))
4 changes: 4 additions & 0 deletions Luke Skrzypek Submission/2 - Javascript/RomanNumerals.js
Original file line number Diff line number Diff line change
@@ -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')))
1 change: 1 addition & 0 deletions Luke Skrzypek Submission/3 - C#/Program.cs
Original file line number Diff line number Diff line change
@@ -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")}");});
10 changes: 10 additions & 0 deletions Luke Skrzypek Submission/3 - C#/RomanNumerals.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

</Project>
6 changes: 6 additions & 0 deletions Luke Skrzypek Submission/README.md
Original file line number Diff line number Diff line change
@@ -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 <file>` - 185 chars without spaces
2) Javascript: `node RomanNumerals.js <file>` - 251 chars without spaces
3) C#: `dotnet build RomanNumerals.csproj` - 288 chars without spaces