Log inBook a Demo
BuildJuniorBackendAuto-graded

Fix a converter that writes 4 as IIII

Following rules exactly, converting correctly in both directions, and refusing invalid input make this a fundamentals warm-up.The Roman-numeral converter never learned subtractive notation. It writes 4 as IIII and 40 as XXXX, and when parsing it simply adds symbols left to right, so IX comes back as 11 rather than 9. Round-trips do not hold and it happily accepts nonsense like IIII or VX. Fix both directions so they produce canonical numerals, parse them correctly, and are genuine inverses across the whole valid range.
25 min
python

You're done when

  • Integer-to-Roman produces canonical numerals, subtractive forms included, on the reference cases.
  • Roman-to-integer returns the correct value on those same cases, reading subtractive pairs properly.
  • Output is canonical for every value from 1 to 3999 — one correct spelling, not merely a parseable one.
  • Invalid numerals are rejected rather than silently given a value.

What it measures

Data structures and algorithmsEncoding subtractive notation as a rule rather than a table of special cases.
PythonImplementing both directions cleanly and validating input on each.
Inverse correctnessVerifying across the whole range rather than on a handful of familiar numbers, which is where canonical form is actually tested.

Your environment

Terminal + editorA full shell in the browser
Claude CodePre-authenticated, no key setup
Isolated microVMYours alone, wiped afterwards

Start this lab

25 min
Start labYou'll sign in to Anthropos to start. The lab opens in a private cloud workspace with Claude Code ready to use.
AI Labs is part of Anthropos Workforce. Not on your plan yet? Book a demo