Skip to content

Commit

Permalink
Create roman.rb
Browse files Browse the repository at this point in the history
  • Loading branch information
JAmixer committed Oct 1, 2018
1 parent ddfccdd commit 7d894f8
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions roman/roman.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
VALUES = [
["M", 1000],
["D", 500],
["C", 100],
["L", 50],
["X", 10],
["V", 5],
["I", 1],
]

def romanize n
roman = ""

VALUES.each do |pair|
letter = pair[0]
value = pair[1]
roman += letter*(n / value)
n = n % value
end
return roman
end

0 comments on commit 7d894f8

Please sign in to comment.