Ad
  • Default User Avatar

    Elegantly put, however, this code fails in situations when two smaller numbers preceed a larger one. Such as 3=IIV, 8=IIX, 300=CCD etc.

    (When looking at the roman numeral in reversed order) When the first small number is compared to the larger number, it passes the test for the elif statement and is subtracted. Then the second small numeral is compared to the first small numeral, which it equals, it is added. Therefore, using this code IIV=5, IIX=10, CCD=500 etc.

    It's a pity they do not use these examples in the test cases

    To fix this last should only be updated in the if and else code blocks