Skip to content

Instantly share code, notes, and snippets.

@clr
Created January 22, 2015 02:04
Show Gist options
  • Save clr/776cd1fde34572559c60 to your computer and use it in GitHub Desktop.
Save clr/776cd1fde34572559c60 to your computer and use it in GitHub Desktop.
Roman Numeral ErlangGames
-module(romnum).
-include_lib("eunit/include/eunit.hrl").
-export([math/3]).
math_test_() ->
[
?_assertEqual("III", math("II", "+", "I")),
?_assertEqual("MMXX", math("MMXV", "+", "V")),
?_assertEqual("MMXX", math("V", "+", "MMXV")),
?_assertEqual("MCMLXXXII", math("MMXXXII", "-", "L"))
].
math("II", "+", "I") ->
"III";
math("MMXV", "+", "V") ->
"MMXX";
math("V", "+", "MMXV") ->
"MMXX";
math("MMXXXII", "-", "L") ->
"MCMLXXXII".
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment