Created
April 28, 2016 19:48
-
-
Save charmainetham/c224f9486737aa2d1197a45a7b0fb133 to your computer and use it in GitHub Desktop.
ROMAN NUMERAL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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