romanex v0.1.0 Romanex
Encode, Decode, and Validate roman numerals.
Letter values are:
M = 1000, D = 500, C = 100, L = 50, X = 10, V = 5, I = 1
The Range of Values representable by roman numerals is:
1 - 4999
Summary
Functions
Decode a Roman Numeral into an Integer
Encode an Integer into a Roman Numeral
Validates a Roman Numeral. Returns true or false
Functions
Specs
decode(String.t) :: {:ok | :error, non_neg_integer}
Decode a Roman Numeral into an Integer
Returns {:ok, result} or {:error, position-of-error}
Lesser value letters that come after Higher value letters signify addition. Only 1 letter may be subtracted from another letter.
EX: 8 is VIII and never IIX.
Subtraction can only occur if the result does not equal another letter.
EX: 50 is never LC, as L is alread 50.
Lesser value letters that come before Higher value letters signify subtraction. Letters that are repeated signify addition. A letter may be repeated at most 3 times.
EX: 4 is always IV and never IIII
Addition can only occur if the result does not equal another letter.
EX: 100 is always C and never LL
V, L, and D may appear only once. I, X, C, and M may appear up to 4 times.