How to add Roman numerals

Adding Roman numerals is actually pretty simple (multiplying or dividing them is the real challenge).

In practice people in the ancient world didn't perform complex calculations using Roman numerals — they used them to record numbers but the calculations themselves were carried out using an abacus.

Algorithm I

Assume we want to add the following two numbers:

MCMLXVII + LXV

I. Tokenize:

M CM L X V I I + L X V

II. Concatenate:

M CM L X V I I L X V

III. Sort:

M CM L L X X V V I I

IV. Reduce:

M CM L L X X V V I I
M CM C   X X X   I I
M M      X X X   I I

MMXXXII

Source

Algorithm II

Assume we want to add the following two numbers:

MCMLXVII + LXV

I. Canonicalize:

MCCCCCCCCCLXVII + LXV

II. Concatenate:

MCCCCCCCCCLXVIILXV

III. Sort:

MCCCCCCCCCLLXXVVII

IV. Reduce:

MCCCCCCCCCLLXXVVII
MCCCCCCCCCC XXX II
MM          XXX II

MMXXXII

Source