Skip to content

Instantly share code, notes, and snippets.

@data-doge
Created February 9, 2015 05:11
Show Gist options
  • Save data-doge/e845d466cb78f0e17e17 to your computer and use it in GitHub Desktop.
Save data-doge/e845d466cb78f0e17e17 to your computer and use it in GitHub Desktop.
bad ass roman numeral soln
$cipher = {
"C" => 100,
"XC" => 90,
"L" => 50,
"XL" => 40,
"X" => 10,
"IX" => 9,
"V" => 5,
"IV" => 4,
"I" => 1
}
def to_roman(num)
output = ""
$cipher.each do |roman, arabic|
output << roman * (num / arabic)
num = num % arabic
end
output
end
puts to_roman(44)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment