Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rabestro/roman-numerals
A simple solution for roman to arabic numerals converter
https://github.com/rabestro/roman-numerals
arabic-numerals regex roman-number-converter roman-numerals streamapi tointfunction
Last synced: about 2 months ago
JSON representation
A simple solution for roman to arabic numerals converter
- Host: GitHub
- URL: https://github.com/rabestro/roman-numerals
- Owner: rabestro
- License: mit
- Created: 2023-07-28T14:39:28.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-07-31T10:42:33.000Z (over 1 year ago)
- Last Synced: 2023-07-31T11:35:36.727Z (over 1 year ago)
- Topics: arabic-numerals, regex, roman-number-converter, roman-numerals, streamapi, tointfunction
- Language: Java
- Homepage:
- Size: 7.81 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Roman to arabic numeral converter
The repository contains AWK script to convert Roman numbers to Arabic numbers, as well as two Java implementations of the converter.
## AWK script
The script is located in the `src/main/awk` directory. It can be run as follows:
```shell
gawk -f roman-to-arabic.awk roman_numerals.txt
```## Java implementations
The Java implementations are located in the `src/main/java` directory.### Usage
```java
var converter = new RomanToArabicConverter();var romanNumerals = Stream.of(
"I", "II", "IV", "V", "VI", "IX", "X", "XIII", "XV", "XL",
"L", "LXXX", "XC", "C", "CD", "D", "CM", "M", "MDCCCLXXXIV");var arabicNumerals = romanNumerals.mapToInt(converter).toArray();
assertThat(arabicNumerals).containsExactly(
1, 2, 4, 5, 6, 9, 10, 13, 15, 40,
50, 80, 90, 100, 400, 500, 900, 1000, 1884);
```