Roman numerals

Translate Roman numbers into Arabic number (https://en.wikipedia.org/wiki/Roman_numerals)

IN

CCLXXXIII

OUT

283

IN

MMMCMXCIX

OUT

3999

IN

I

OUT

1

IN

III

OUT

3

IN

VIII

OUT

8

IN

XL

OUT

40

IN

LX

OUT

60

IN

LXII

OUT

62

IN

CC

OUT

200

IN

CD

OUT

400

IN

MCMLXXXVIII

OUT

1988
Login to submit solution


35 symbols pyth
Wed Nov 23 18:05:28 2016 Sait2000
sm-K.<^5/hd2/d2*yZ<Z=ZKxL"IVXLCDM"z
37 symbols pyth
Fri Oct 28 04:06:19 2016 Sait2000
u+G-K.<^5/hH2/H2*yZ<Z=ZKxL"IVXLCDM"z0
40 symbols pyth
Fri Oct 28 03:55:54 2016 Sait2000
VxL"IVXLCDM"z=+Y-K.<^5/hN2/N2*yZ<Z=ZK)sY
41 symbols pyth
Fri Oct 28 03:53:29 2016 Sait2000
JZVxL"IVXLCDM"z=+J-K.<^5/hN2/N2*yZ<Z=ZK)J
42 symbols pyth
Mon Sep 19 16:50:32 2016 Sait2000
JZVxL"IVXLCDM"z=+J-K.<^5/hN2/N2**2Z<Z=ZK)J
44 symbols pyth
Mon Sep 19 16:47:26 2016 Sait2000
JZVxL"IVXLCDM"zK.<^5/hN2/N2=+J-K**2Z>KZ=ZK)J
82 symbols perl
Thu Oct 2 17:05:01 2014 vakorol
#!/usr/bin/perl -paF
y/IVXLCDM/0-6/,$x-=2*($s=$l)*($s<($l=10**($_/2)*2.5**($_%2/2)))-$l for@F;$_=$x
83 symbols perl
Fri Sep 26 00:35:33 2014 gabrielmad
#!/usr/bin/perl -paF
y/IVXLCDM/0-6/,$x+=2*($s=$l)*($s<($l=10**($_/2)*2.5**($_%2/2)))-$l for@F;$_=-$x
84 symbols ruby2.0
Mon Oct 6 14:48:32 2014 fl00r
x=l=0
$<.chars{|a|c='IVXLCDM'=~/#{a}/;c=5**(c%2)*10**(c/2);x+=c;c>l&&x-=l*2;l=c}
p x
84 symbols ruby2.0
Wed Aug 17 19:06:57 2016 vitormd
x=l=0
$<.chars{|a|c='IVXLCDM'=~/#{a}/;c=5**(c%2)*10**(c/2);x+=c;c>l&&x-=l*2;l=c}
p x
84 symbols ruby
Thu Oct 27 08:17:06 2016 k-mx
x=l=0
$<.chars{|a|c='IVXLCDM'=~/#{a}/;c=5**(c%2)*10**(c/2);x+=c;c>l&&x-=l*2;l=c}
p x
85 symbols ruby2.0
Mon Oct 6 14:45:25 2014 fl00r
x=l=0
$<.chars{|a|c='IVXLCDM'.index(a);c=5**(c%2)*10**(c/2);x+=c;c>l&&x-=l*2;l=c}
p x
86 symbols perl
Tue Sep 23 16:27:52 2014 vakorol
#!/usr/bin/perl -paF
for(@F){y/IVXLCDM/0-6/;$x+=2*($s=$l)*($s<($l=10**($_/2)*2.5**($_%2/2)))-$l};$_=-$x
88 symbols perl
Thu Sep 4 20:57:14 2014 gabrielmad
#!/usr/bin/perl -paF
$x+=($d={M,1000,D,500,C,100,L,50,X,10,V,5,I,1}->{$_})-2*$l*($l<$d),$l=$d for@F;$_=$x
89 symbols ruby2.0
Sun Oct 5 18:11:14 2014 fl00r
x=l=0
$<.chars{|a|c='IVXLCDM'.index(a)and(c=5**(c%2)*10**(c/2);x+=c;c>l&&x-=l*2;l=c)}
p x
90 symbols perl
Thu Sep 4 20:53:05 2014 gabrielmad
#!/usr/bin/perl -paF
$x+=($d={(M,1000,D,500,C,100,L,50,X,10,V,5,I,1)}->{$_})-2*$l*($l<$d),$l=$d for@F;$_=$x
90 symbols python3
Mon Sep 12 17:31:36 2016 Sait2000
x=p=0
for i in map("IVXLCDM".find,input()):n=5**(-~i//2)<<i//2;x+=n-p*2*(n>p);p=n
print(x)
91 symbols python2
Thu Sep 4 18:44:42 2014 xsot
x=p=0
for c in raw_input():i="IVXLCDM".find(c);n=5**(-~i/2)<<i/2;x+=n-p*2*(n>p);p=n
print x
91 symbols ruby2.0
Sun Oct 5 04:20:42 2014 fl00r
x=l=0
$<.chars{|a|c='IVXLCDM'.index(a)||next;c=5**(c%2)*10**(c/2);x+=c;c>l&&x-=l*2;l=c}
p x
91 symbols ruby2.0
Sun Oct 5 04:34:59 2014 fl00r
x=l=0
$<.chars{|a|c='IVXLCDM'.index(a)||next;c=5**(c%2)*10**(c/2);x+=c;c>l&&x-=l*2;l=c}
p x

View all solutions