Ad
  • Custom User Avatar

    Basically have ruby check the syntax for you? :p

  • Default User Avatar

    You can argue that IVXX=14 or IVXX=16. It is 20 (XX) minus 5 (V) minus 1 (I), or it is 20 (XX) minus 4 (IV). That's the reason why we avoid using confusing numerals like that.
    Arguably VIXX would be valid, but this code also won't like it. (This code returns 24, while we mean 20-6, or 20-1-5). But notice that the notation is rubbish anyway: XIV=14 or XVI=16, and both are shorter.

    Actually, the definition of Roman numerals used in this problem only allows a single I before V or X, a single X before L or C, and a single C before D or M. No other "subtraction" is allowed. So all these weird cases discussed above cannot occur.
    As the problem description states: "Modern Roman numerals are written by expressing each decimal digit of the number to be encoded separately, starting with the leftmost digit and skipping any 0s."

    In other words: all these cases are handled properly by the code. And the code even extends on this, by supporting IM (as 999), VM (as 995), IIIIIIIIIIIIIIII (16), etc., which would also be non-ambiguous.

  • Default User Avatar

    That's not a valid Roman number, why should the solution give a valid result?

  • Custom User Avatar

    What language do you use? May you try submitting your solution instead of just testing it (it should allow me to see it).

  • Custom User Avatar

    You have a timeout ?

  • Custom User Avatar

    As i said in the description there is always a loop so the object_id should not increment infinitely.
    I try to print the object_id as you did and i didn't see any problem with the id.
    Maybe try to compare the object itself.