Skip to content

Commit 5a2d2e1

Browse files
Code golf submission - Roman Numerals
Reads numbers (separated by newlines) from an absolute file path passed in on command line. Outputs the numbers as Roman numerals to the console. Should be 253 characters.
1 parent 31dcf4f commit 5a2d2e1

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

Luke Skrzypek Submission/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Requires node to be installed.
2+
3+
4+
Usage:
5+
`node RomanNumerals.js <FullInputFilePath>`
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
o=require('fs')
2+
F=(n,f,i,d)=>n<4?f.repeat(n):n==4?f+i:n<9?i+f.repeat(n-5):f+d
3+
o.readFileSync(process.argv[2],'utf8').split('\n').forEach(x=>{n=-(-x)
4+
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'))})

0 commit comments

Comments
 (0)