View Code? Open in Web Editor
NEW
Application to convert roman numerals
License: The Unlicense
JavaScript 32.86%
TypeScript 67.14%
numeromans's Introduction
numeromans's People
Contributors
Watchers
numeromans's Issues
Information:
- description of the problem
- description of how the problem was solved
- instructions how to run the code
- license
Start a node project with
and configure the package.json file.
Create a route to test the application, where it receives a character and return the response in JSON format.
Route example
http://url:{port}/arabic?character=10
Receive a string with a roman numeral, like CCXII
, and convert it to its arabic numerals, 212
.
Considering the roman characters and its values:
Character |
Value |
I |
1 |
V |
5 |
X |
10 |
L |
50 |
C |
100 |
D |
500 |
M |
1000 |
- For each character on a string, convert it to its value and sum them all.
- If the value of the next character is bigger, then subtract instead of sum
Not allowed operations
- any other character that does not belong to the roman numeral character list
- more than 3 repetitions of any character
- multiple repetition of the characters: [ V, L, D ]
- multiple subtractions of the characters: [ I, X, C ]
Install express
and its types:
Install husky
npm install husky --save-dev
Create a route to test the application, where it receives a character and return the response in JSON format.
Route example
http://url:{port}/roman?character=X
Install and configure typescript with:
npm i -D typescript ts-node
and
Update the tsconfig.json to configure the rootDir and outDir
Install eslint configured to airbnb:
Install prettier
npm install --save-dev --save-exact prettier
To convert the biggest roman number, four Ms are needed:
The validation that asserts only 3 character occurrences of each letter must have an exception if the character requested is M.
Install nodemon
Then configure the server.
Install Jest
npm i -D jest @types/jest ts-jest