CSharp ConvertRomanNum

From scripting
Jump to: navigation, search
        static string ConvertRomanNum(long InputNum)
            //0001D LLC 2015 Nick Pisca
            //long InputNum = 234; 

            string[,] RNs = new string[,] {
                            {"", "I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX"},
                            {"", "X", "XX", "XXX", "XL", "L", "LX", "LXX", "LXXX", "XC"},
                            {"", "C", "CC", "CCC", "CD", "D", "DC", "DCC", "DCCC", "CM"},
                            {"", "M", "MM", "MMM", "Mv", "v", "vM", "vMM", "vMMM", "Mx" },
                            {"", "x", "xx", "xxx", "xl", "l", "lx", "lxx", "lxxx", "xc" }}; 

            var intArr = InputNum.ToString().Reverse().ToArray();
            int len = intArr.Count();
            string RN = "";
            int i = len;

            while (i-- > 0)
                RN += RNs[i,Int32.Parse(intArr[i].ToString())];

            return RN;

This subroutine was used in the development of the Mega-Dots World's Toughest Connect-the-Dots Puzzles.

Unrelated MEL scripting help located here: YSYT.