Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Can we replace ? solution in Clear category for [old] Roman Numerals by wolfnether
"use strict";
function romanNumerals(number) {
return 'I'.repeat(number)
.replace(/IIIII/g, 'V')
.replace(/IIII/, 'IV')
.replace(/VV/g, 'X')
.replace(/VIV/, 'IX')
.replace(/XXXXX/g, 'L')
.replace(/XXXX/, 'XL')
.replace(/LL/g, 'C')
.replace(/LXL/, 'XC')
.replace(/CCCCC/g, 'D')
.replace(/CCCC/, 'CD')
.replace(/DD/g, 'M')
.replace(/DCD/, 'CM')
}
var assert = require('assert');
if (!global.is_checking) {
assert.equal(romanNumerals(1), 'I', "I");
assert.equal(romanNumerals(2), 'II', "II");
assert.equal(romanNumerals(3), 'III', "III");
assert.equal(romanNumerals(4), 'IV', "IV");
assert.equal(romanNumerals(5), 'V', "V");
assert.equal(romanNumerals(6), 'VI', "VI");
assert.equal(romanNumerals(7), 'VII', "VII");
assert.equal(romanNumerals(8), 'VIII', "VIII");
assert.equal(romanNumerals(9), 'IX', "IX");
assert.equal(romanNumerals(10), 'X', "X");
assert.equal(romanNumerals(76), 'LXXVI', "Second");
assert.equal(romanNumerals(499), 'CDXCIX', "Third");
assert.equal(romanNumerals(3888), 'MMMDCCCLXXXVIII', "Forth");
console.log("Done! Go Check!");
}
Aug. 18, 2017
Comments: