Roman Numeral in Dart

Published on 20 October 2019 (Updated: 21 October 2019)

Welcome to the Roman Numeral in Dart page! Here, you'll find the source code for this program as well as a description of how the program works.

Current Solution

void main(List<String> args) {
    Map numerals = numeral_map();
    List<int> values = [0];
    for(int i=0; i<args[0].length; i++){

    int sum = values[values.length-1];
    for(int i=1; i<values.length; i++){
      sum = (values[i]>values[i-1]) ? sum-values[i-1] : sum+values[i-1]; 
  on RangeError{
    print("Usage: please provide a string of roman numerals");
  on NoSuchMethodError{
    print("Error: invalid string of roman numerals");

Map numeral_map(){
  var numerals = new Map();
  numerals['I'] = 1;
  numerals['V'] = 5;
  numerals['X'] = 10;
  numerals['L'] = 50;
  numerals['C'] = 100;
  numerals['D'] = 500;
  numerals['M'] = 1000;
  return numerals;

Roman Numeral in Dart was written by:

If you see anything you'd like to change or update, please consider contributing.

How to Implement the Solution

No 'How to Implement the Solution' section available. Please consider contributing.

How to Run the Solution

No 'How to Run the Solution' section available. Please consider contributing.