<commit_before># 10.exercise.06.md

## Statement

Define a **Roman\_int** class for holding Roman numerals (as **int**s) with a
**<<** and **>>**. Provide **Roman\_int** with an **as\_int()** member that
returns the **int** value, so that if **r** is a **Roman\_int**, we can write
**cout << "Roman " << r << " equals " << r.as\_int() << '\n';**.

## Analysis

### Roman numerals

We were told that Roman numerals are expressed by a set of letters with
different values: M, D, C, L, X, V, and I, respectively equivalents to 1000,
500, 100, 50, 10, 5 and 1. The awkwardness comes when we were told that, to
express 900, we must write CM, kind of 100 substracted from 1000.

For this exercise I prefer to take a different approach where the letters
aren't the core concept but _particles_. I call _particles_ to the letters or
combinations of them that have a defined value. The particles are (read below
for explanation about particles properties):

| Particle | Value | Repetition | Conflicts with | Inhibits |
| -------- |:-----:|:----------:|:--------------:|:--------:|
|    M     | 1000  |    4       | -              |   -      |
|    CM    | 900   |    1       | D, CD          |   C      |
|    D     | 500   |    1       | CM, CD         |   -      |
|    CD    | 400   |    1       | CM, D          |   C      |
|    C     | 100   |    4       | -              |   -      |
|    XC    | 90    |    1       | L, XL          |   X      |
|    L     | 50    |    1       | XC, XL         |   -      |
|    XL    | 40    |    1       | XC, L          |   X      |
|    X     | 10    |    4       | -              |   -      |
|    IX    | 9     |    1       | V, IV          |   I      |
|    V     | 5     |    1       | IX, IV         |   -      |
|    IV    | 4     |    1       | IX, V          |   I      |
|    I     | 1     |    4       | -              |   -      |

These particles could appear or not, and some of them could be consecutively
repeated. There is some discussion about if these particles could be repeated 3
or 4 times, so both IV and IIII means 4. Since it barely affects my analysis I
will take the _4-repetition_ option. With this decision the numbers we can
represent range from 1 to 49999 (remember that Roman numerals have no concept
of zero).

The advantage of _particles_ is that they appear in order of decreasing
magnitude, so we could parse a Roman numeral by simply traversing the
_particles_ from the greatest to the lowest.

There are some particles that conflict with others. In sets **_{CM, D, CD}**_,
**_{XC, L, XL}**_ and **_{IX, V, IV}**_, only one _particle_ from the set could
appear in the Roman numeral. Explanation: once CM (900) appears, there is no
interest in adding D (500) or CD (400).

There are some _particles_ that inhibit others; if CM (900) or CD (400) appear,
there is no chance for C (100) to appear after since 900+100 is 1000 and
expressed with M, and 400+100 is 500 and expressed with D.

Taking account of all this, I plan to implement a lookup table that condenses
all the information contained in the former table.

### Input behavior

I want **>>** operator to work on **Roman\_int** as similar as it does on
fundamental types. I mean, if we have an input as _3e10-0.2_ and we read two
**double**s, we obtain _3e10_ and _-0.2_.

So, if we have an input as _MMXCCV_, that at first sight seems wrong, and the
program reads two **Roman\_int**s, I want to obtain _MMX_ and _CCV_ and not an
error.  This forces me to work on the **char** level instead of working with
strings and also bind me to return to the input stream those characters that,
previously read, don't belong to the **Roman\_int** currently read.

As the book already brings up, this behavior can be difficult to obtain.

## Design
<commit_msg>Trying to reconcile Gitlab and Github markdown behavior regarding to emphasis<commit_after># 10.exercise.06.md

## Statement

Define a **Roman\_int** class for holding Roman numerals (as **int**s) with a
**<<** and **>>**. Provide **Roman\_int** with an **as\_int()** member that
returns the **int** value, so that if **r** is a **Roman\_int**, we can write
**cout << "Roman " << r << " equals " << r.as\_int() << '\n';**.

## Analysis

### Roman numerals

We were told that Roman numerals are expressed by a set of letters with
different values: M, D, C, L, X, V, and I, respectively equivalents to 1000,
500, 100, 50, 10, 5 and 1. The awkwardness comes when we were told that, to
express 900, we must write CM, kind of 100 substracted from 1000.

For this exercise I prefer to take a different approach where the letters
aren't the core concept but _particles_. I call _particles_ to the letters or
combinations of them that have a defined value. The particles are (read below
for explanation about particles properties):

| Particle | Value | Repetition | Conflicts with | Inhibits |
| -------- |:-----:|:----------:|:--------------:|:--------:|
|    M     | 1000  |    4       | -              |   -      |
|    CM    | 900   |    1       | D, CD          |   C      |
|    D     | 500   |    1       | CM, CD         |   -      |
|    CD    | 400   |    1       | CM, D          |   C      |
|    C     | 100   |    4       | -              |   -      |
|    XC    | 90    |    1       | L, XL          |   X      |
|    L     | 50    |    1       | XC, XL         |   -      |
|    XL    | 40    |    1       | XC, L          |   X      |
|    X     | 10    |    4       | -              |   -      |
|    IX    | 9     |    1       | V, IV          |   I      |
|    V     | 5     |    1       | IX, IV         |   -      |
|    IV    | 4     |    1       | IX, V          |   I      |
|    I     | 1     |    4       | -              |   -      |

These particles could appear or not, and some of them could be consecutively
repeated. There is some discussion about if these particles could be repeated 3
or 4 times, so both IV and IIII means 4. Since it barely affects my analysis I
will take the _4-repetition_ option. With this decision the numbers we can
represent range from 1 to 49999 (remember that Roman numerals have no concept
of zero).

The advantage of _particles_ is that they appear in order of decreasing
magnitude, so we could parse a Roman numeral by simply traversing the
_particles_ from the greatest to the lowest.

There are some particles that conflict with others. In sets ***{CM, D, CD}***,
***{XC, L, XL}*** and ***{IX, V, IV}***, only one _particle_ from the set could
appear in the Roman numeral. Explanation: once CM (900) appears, there is no
interest in adding D (500) or CD (400).

There are some _particles_ that inhibit others; if CM (900) or CD (400) appear,
there is no chance for C (100) to appear after since 900+100 is 1000 and
expressed with M, and 400+100 is 500 and expressed with D.

Taking account of all this, I plan to implement a lookup table that condenses
all the information contained in the former table.

### Input behavior

I want **>>** operator to work on **Roman\_int** as similar as it does on
fundamental types. I mean, if we have an input as _3e10-0.2_ and we read two
**double**s, we obtain _3e10_ and _-0.2_.

So, if we have an input as _MMXCCV_, that at first sight seems wrong, and the
program reads two **Roman\_int**s, I want to obtain _MMX_ and _CCV_ and not an
error.  This forces me to work on the **char** level instead of working with
strings and also bind me to return to the input stream those characters that,
previously read, don't belong to the **Roman\_int** currently read.

As the book already brings up, this behavior can be difficult to obtain.

## Design

{'fraction_non_alphanumeric': 0.10417213329834689, 'fraction_numerical': 0.03358698504329572, 'mean_word_length': 2.084985835694051, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 20, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4701374', 'n_tokens_mistral': 2487, 'n_tokens_neox': 2228, 'n_words': 1096}