Skip to content

Instantly share code, notes, and snippets.

@alfredodev
Created January 10, 2019 09:32
Show Gist options
  • Save alfredodev/e2923009d3b9f09eb2e2a1d73e378959 to your computer and use it in GitHub Desktop.
Save alfredodev/e2923009d3b9f09eb2e2a1d73e378959 to your computer and use it in GitHub Desktop.

The Roman Numeral Kata

We would like to be able to convert Arabic numbers into their Roman numeral equivalents. In the interest of simplicity, we'll only be dealing with numbers no greater than 50.

The Romans wrote their numbers using letters:

Number  Numeral
---------------
1       I       
5       V       
10      X
50      L

There were certain rules that the numerals followed which should be observed:

  • The '1' symbols ('I' and 'X') can be subtracted from the 2 next highest values ('V' and 'L') to form 'IV', 'IX' and 'XL'.
  • The symbols 'I' and 'X' can be repeated at most 3 times in a row.
  • The symbols 'V' and 'L' can never be repeated.

Getting Started

The interface to your checkout will initially consist of one method:

public string Convert(int amount)

Here, amount represents the decimal amount and the value this method returns is the string of numerals. Whilst we have provided you with this initial interface, feel free to change it as you develop the solution.

Tips

  • Relax. This is not a one sided interview. The interviewer will help you along.
  • Treat the interviewer as if he/she is your potential team mate.
  • You don’t need to solve the problem by yourself. If you get stuck, ask for help.
  • Discuss possible ideas. Don’t keep them to yourself. Think out loud.
  • Say why you do certain things. For example:
    • "In my experience, I’ve found it pattern X more useful than pattern Y for this scenario"
    • "I tend to write my unit tests in a BDD style, hope you don’t mind"
  • Listen to the interviewer - they may be offering hints to solve the problem.
  • Take small steps. You should always be able to go to a green state quickly.
  • Stick to the red, green and refactor steps.
  • Focus on solving the problem with your potential team mate, instead of showing how awesome your implementation is.

Credits: Adapted from http://agilekatas.co.uk/katas/RomanNumerals-Kata

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment