0

Roman numeral logic correction

I've created a roman numeral to decimal converter, in which it takes the users input as roman numerals, which is then iterated through and assigned to it's equivalent dictionary value. but when trying to add values like XII(12) or III(3), i get values that are often 1 number higher than they are supposed to be, like 13 or 4. what makes this harder is the consistency at which this happens - only for repeat values. what am i doing wrong? source code: https://code.sololearn.com/cawSz1yqt8o3

27th Dec 2017, 12:01 PM
X-1
X-1 - avatar
1 Antwort
+ 1
hi, first, amend you rNumeral to include 'IV, IX, ...CM' then iterate from highest , eg MCMIX will be 1000+900+9
27th Dec 2017, 8:36 PM
yuri