Permalink
Browse files

refactor: follow the pattern for 9 and 10

  • Loading branch information...
antonydenyer committed Nov 16, 2017
1 parent da5e6a7 commit 78a7c459ce47d1788e8a5c4f60215136af5d6286
Showing with 8 additions and 8 deletions.
  1. +8 −8 lib/roman.ex
View
@@ -1,5 +1,13 @@
defmodule Roman do
def to_roman(number, roman_accumulator) when number >= 10 do
to_roman(number - 10, roman_accumulator <> "X")
end
def to_roman(number, roman_accumulator) when number >= 9 do
to_roman(number - 9, roman_accumulator <> "IX")
end
def to_roman(number, roman_accumulator) when number >= 5 do
to_roman(number - 5, roman_accumulator <> "V")
end
@@ -11,14 +19,6 @@ defmodule Roman do
def to_roman(number, roman_accumulator) when number <= 3 do
roman_accumulator <> String.duplicate("I", number)
end
def to_roman(number) when number >= 10 do
to_roman(number - 10, "X")
end
def to_roman(number) when number >= 9 do
to_roman(number - 9, "IX")
end
def to_roman(number) do
to_roman(number, "")

0 comments on commit 78a7c45

Please sign in to comment.