Code: Select all
r = #.input("Input Roman number:")
n = [1,5,10,50,100,500,1000]
a,m = 0
> i, #.size(r)..1, -1
v,c = n[#.pos("IVXLCDM",#.mid(#.upper(r),i))]
? v<m, v = -v
? c>m, m = c
a += v
<
#.output("Arabic number: ",a)
Code: Select all
r = #.input("Input Roman number:")
n = [1,5,10,50,100,500,1000]
a,m = 0
> i, #.size(r)..1, -1
v,c = n[#.pos("IVXLCDM",#.mid(#.upper(r),i))]
? v<m, v = -v
? c>m, m = c
a += v
<
#.output("Arabic number: ",a)