Ad
  • Custom User Avatar

    Situations like you mentioned ( 3 being writen as 'IIV' ) won't occur since 'IIV' is not a valid roman number (Kata was to create a decoder for VALID roman numbers)

  • 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