Skip to content

Instantly share code, notes, and snippets.

@zspencer
Created April 14, 2015 01:13
Show Gist options
  • Save zspencer/92969da8dcdf126919f1 to your computer and use it in GitHub Desktop.
Save zspencer/92969da8dcdf126919f1 to your computer and use it in GitHub Desktop.
describe "Converting Arabic Numerals to Roman Numerals" do
NUMERAL_TRANSLATIONS = {
1 => "I",
2 => "II",
5 => "V",
10 => "X"
}
NUMERAL_TRANSLATIONS.each_pair do |arabic, roman|
it "converts #{arabic} to #{roman}" do
expect(arabic_to_roman(arabic)).to eql(roman)
end
end
end
ARABIC_TO_ROMAN_MAPPING = {
1 => "I",
2 => "II",
5 => "V",
10 => "X"
}
def arabic_to_roman(number)
ARABIC_TO_ROMAN_MAPPING[number]
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment