Skip to content

Instantly share code, notes, and snippets.

@MrBean83
Created September 17, 2013 01:20
Show Gist options
  • Save MrBean83/6588948 to your computer and use it in GitHub Desktop.
Save MrBean83/6588948 to your computer and use it in GitHub Desktop.
class RomanNumerals
def initialize
self.re_pop
end
def converter(test_number, discard = 0, key = @roman_numbers.keys.first)
return "" if test_number == 0
(@roman_numbers[key] * (test_number / key)) +
converter(test_number % key, @roman_numbers.delete(key))
end
def re_pop
@roman_numbers = {
1000 => "M",
900 => "CM",
500 => "D",
400 => "CD",
100 => "C",
90 => "XC",
50 => "L",
40 => "XL",
10 => "X",
9 => "IX",
5 => "V",
4 => "IV",
1 => "I"
}
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment