June 2018 Update
This commit is contained in:
parent
ba8067c3b7
commit
22f33d4004
5278 changed files with 84726 additions and 14379 deletions
|
|
@ -4,7 +4,6 @@ defmodule Roman_numeral do
|
|||
def decode([h1, h2 | rest]) do
|
||||
case {to_value(h1), to_value(h2)} do
|
||||
{v1, v2} when v1 < v2 -> v2 - v1 + decode(rest)
|
||||
{v1, v1} -> v1 + v1 + decode(rest)
|
||||
{v1, _} -> v1 + decode([h2 | rest])
|
||||
end
|
||||
end
|
||||
|
|
@ -18,6 +17,6 @@ defmodule Roman_numeral do
|
|||
defp to_value(?I), do: 1
|
||||
end
|
||||
|
||||
Enum.each(['MCMXC', 'MMVIII', 'MDCLXVI'], fn clist ->
|
||||
Enum.each(['MCMXC', 'MMVIII', 'MDCLXVI', 'IIIID'], fn clist ->
|
||||
IO.puts "#{clist}\t: #{Roman_numeral.decode(clist)}"
|
||||
end)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue