Skip to content

Instantly share code, notes, and snippets.

@charmainetham
Created April 28, 2016 19:48
Show Gist options
  • Save charmainetham/c224f9486737aa2d1197a45a7b0fb133 to your computer and use it in GitHub Desktop.
Save charmainetham/c224f9486737aa2d1197a45a7b0fb133 to your computer and use it in GitHub Desktop.
ROMAN NUMERAL
@nums = { "M"=>1000, "D"=>500, "C"=>100, "L"=>50, "X" =>10, "V" =>5, "I" =>1}
def to_roman(number)
roman = ""
@nums.each do |rom,num|
while number >= num
roman << rom
number -= num # TODO update number to take remainder
end
end
roman
end
puts to_roman(100).inspect
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment