Permalink
Browse files

feat(X): implement 9 and 10

  • Loading branch information...
antonydenyer committed Nov 16, 2017
1 parent c79d40b commit 2385106fd1d5fc222dc665f2b626d8430aa7c1dd
Showing with 20 additions and 0 deletions.
  1. +8 −0 lib/roman.ex
  2. +12 −0 test/roman_test.exs
View
@@ -4,6 +4,14 @@ defmodule Roman 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) when number >= 5 do
to_roman(number - 5, "V")
end
View
@@ -21,4 +21,16 @@ defmodule RomanTest do
assert Roman.to_roman(6) == "VI"
end
test "nine is IX" do
assert Roman.to_roman(9) == "IX"
end
test "ten is X" do
assert Roman.to_roman(10) == "X"
end
test "eleven is XI" do
assert Roman.to_roman(11) == "XI"
end
end

0 comments on commit 2385106

Please sign in to comment.